Thread: Issues compiling with static - linker missing .o files?

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    199

    Cool Issues compiling with static - linker missing .o files?

    Hi pretty much as topic says, I'm compiling a DLL very much like one I've already compiled without problems but this time the linker is complaining it cannot find a load of .o files. Strange as I thought it was only things like .cpp files and the like which were converted to .o files to be linked against?

    Anyway here is the error message:

    mingw32-g++.exe: obj\Debug\libZFXRenderer.o: No such file or directory
    mingw32-g++.exe: obj\Debug\libgdi32.o: No such file or directory
    mingw32-g++.exe: obj\Debug\libvfw32.o: No such file or directory
    mingw32-g++.exe: obj\Debug\libzfx3d.o: No such file or directory

    And it's correct there's nothing in the Debug folder relating to any of the static libraries there. But there never is anyway, so why is it looking for this? It never did this the last DLL I compiled and that came with 3 static libraries needed to compile. None of which ended up as .o files in the debug folder either for that matter.

    Seems rather odd. Maybe a bad setting or something. I've included all required statics in the linker settings too. I don't know could a bad pragma comment or something cause this?

    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Is your project still dependent on the original object files?

    If you moved some object files into a libary, you need to remove the dependencies on the individual objects.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    199
    Thanks for the reply. Looks like I'm mis-understanding something here. I always thought that making a .a file - static library - that meant all the stuff the linker needed to link to was in the static library and that would compile fine provided the linker could find them at build time. The thing that's really puzzling me is that even the native windows static libraries the vfw and gdi stuff is being rejected. It seems the linker is expecting to find it's resources as .o files in the debug directory, rather than doing what I thought it should and linking to the static libraries in the project folder.

    I'm still stuck, any more ideas?

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    199
    I have found the problem. It was my own fault. I stupidly added the static libraries to the project and so I can only assue the linker expected to find corresponding .o files after the compiler was finished. When it couldn't find them it complained. Although that is now fixed I have another problem now anyway but that looks like it will be a bit more straight forward. If I can get this fixed I'll post a screenshot of the running demo when I've finally built the .exe and .dll file to go with it

    Cheers.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    199
    Ok thanks for the help so far. I have one more question though. As I said above I have now found this problem's source. Great But this new problem is probably much more trivial but it's still eluding me! Here's a post I made on another forum:

    I have another problem now. The math library is not properly built. I always get this warning when compiling:

    |93|warning: inline function 'void ZFXVector::Normalize()' used but never defined|

    Now the classes and their member functions are all declared in one big file called zfx3d.h. Their member functions however are not defined in this file, they are all defined in subsidiary .cpp files. Fine. Nice bit of organization by the looks of things, something I could take a few lessons from myself for that matter.

    Problem is, these function definitions in the .cpp files are not being picked up at compile time and as such are not ending up defined in the resulting static library. This is causing build errors when I come to compile the DLL file later on which has stuff in it that wants to use these functions - yet it can't find their definition - so it refuses the build.

    Any idea how I can allow the compiler to pick-up these defintions in the .cpp files during the build?

    Thanks in advance

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    199
    Ok update, turns out you cannot, at least in the compiler I'm using have inline functions defined in seperate files from their prototypes. It is demanded they are defined there and then in the same file. Ok fair enough.

    Also however there are now problems with inline functions not being found in the static library when used by an application or when compiling another library using this pre-compiled static library. The inline functions always return an undefined reference error. Until I have pinned this down further I will not be able to add anything more.

    Thanks for the help so far

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Sure, you can't have it both ways.

    Either the function is implemented ONCE in the library, or it is implemented inline every time you call it. To call it inline, you need the inline-able code in the header file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issues compiling multiple c files.
    By Overworked_PhD in forum C Programming
    Replies: 2
    Last Post: 10-11-2009, 04:25 PM
  2. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  5. linker error, using static member
    By Chiel in forum C++ Programming
    Replies: 6
    Last Post: 06-28-2003, 08:40 PM