Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, So I read ld can link with ELF or COFF libraries. But now how do I tell GCC via the header file that the names have leading underscores? I've ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    11

    Linking with COFF library?


    Hi,

    So I read ld can link with ELF or COFF libraries. But now how do I tell GCC via the header file that the names have leading underscores? I've already tried the __attribute__((cdecl)) and that doesn't seem to work. I only have the header and the COFF .lib so I need to tell GCC for these functions defined in the header to use the underscore naming style. Can you tell me how to do that please. TIA!!

  2. #2
    Just Joined!
    Join Date
    Sep 2011
    Posts
    11
    Okay, so the docs say ld should work with COFF files, but maybe not COFF libraries because during link it said it didn't like the file format. In any case, the reason I wanted to try linking with COFF file is because gcc and ld are being a pain. I converted the COFF library to ELF32, but during linking I get all kinds of undefined references to about 10 variables. This is a third party library and I can link it using open watom to DOS targets, Linux Targets, Other Targets no problems (I always use the option dead code elimination in watcom). When I look at the map file created by watcom, I see those symbols and they are marked as unreferenced, no complaints, everything works fine. I was playing around with the various -fdata-sections and -ffunction-sections and --gc-sections (of course static linking) but I guess that only works if you can compile the source. I'm not sure if it's ld or the ELF format, but it can't strip what open watcom can. So I found this option --warn-unresolved-symbols and now it completes linking and creating the executable (I don't like using that option, I'll have to watch every time I add new stuff, but stuck doing it) Everything seems to work fine when using the various function so that third party library. The map file for the gcc created app doesn't have any note of any of the symbols it was complaining about before. Obviously those symbols aren't needed so why does ld error out and talk about "undefined reference" when not needed, I thought linux was an up to date modern system with the best of everything available (yet I find the DOS open watcom seems to do a better job at a lot of things). ???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •