Skip to main content
gamedev.net
🔒 Locked

Creating static libraries (.lib's)

Started by Alan Kemp 1 reply 200+ views
Original Post
Alan Kemp
Alan Kemp
Hi, I am trying to put all my gui code into a .lib file so I can keep its source central, and also to allow me to easily include it into my other projects. I have built the .lib file no problems, but when I include it into a project I get a link errors:
    
libcd.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_new_group already defined in LIBCMT.lib(sbheap.obj)
libcd.lib(sbheap.obj) : error LNK2005: ___sbh_resize_block already defined in LIBCMT.lib(sbheap.obj)
libcd.lib(sbheap.obj) : error LNK2005: ___sbh_heapmin already defined in LIBCMT.lib(sbheap.obj)
libcd.lib(sbheap.obj) : error LNK2005: ___sbh_heap_check already defined in LIBCMT.lib(sbheap.obj)
libcd.lib(isctype.obj) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
LIBCMT.lib(crt0init.obj) : warning LNK4098: defaultlib 'libcd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    
There are 44 errors reported (I just posted a few from the end). I know how to fix this in the project I am including the library into (just specify /nodefaultlib: libcd.lib as the message says). I would however prefer to fix this in the actual library project. Is this possible? I tried adding /nodefaultlib statements to the library project, but it didn't make any difference (to the size of the generated .lib or to the error messages generated). Thanks for your time, Alan [edited by - AlanKemp on January 7, 2003 6:18:58 PM]
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Alan Kemp
Alan Kemp
No-one got any ideas?

It seems a bit kludgy to have to use nodefaultlib in the final project, and I wonder what is going to happen if I decide to put something else out into a static library. Is including two libraries into one project going bring back the link errors?

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
DerekSaw
DerekSaw
A rough guess is that you are linking a single threaded lib/obj with some multi threaded lib/obj.
"after many years of singularity, i'm still searching n the event horizon" o

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.