PDA

View Full Version : Cpw compiled with static library.



jpummill
02-25-2002, 11:54 AM
I have a working Cpw application compiled to use dll's.

When I switch the #define to use the static library, I get the message "Cannot open file - Cpw.lib".

Is the CpwLib.lib file in "\library\output\win32" the file that is needed?

When I move this file to my source directory and rename it "Cpw.lib", I get the following errors:

--------------------Configuration: cpw3 - Win32 Debug--------------------
Compiling...
cpw3.cpp
Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBCD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBCD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in LIBCD.lib(sprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _printf already defined in LIBCD.lib(printf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _realloc already defined in LIBCD.lib(dbgheap.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in LIBCD.lib(memmove.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _tolower already defined in LIBCD.lib(tolower.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/cpw3.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

cpw3.exe - 11 error(s), 1 warning(s)
-------

Thanks for any help,
John

jmathies
02-25-2002, 07:20 PM
Hey John,

Ok on the Cpw.lib issue, there is a mistake in the cpw_config.h - line 283 should be

#pragma comment (lib, "CpwLib.lib" )

instead of

#pragma comment (lib, "Cpw.lib" )

Thanks for finding it. http://www.opengl.org/discussion_boards/ubb/smile.gif

On your compile errors -

You've got a mutlithreaded, singlethreaded runtime library situation going on there. LIBCD.lib is the single threaded runtime lib (debug) and the default project settings for the static Cpwlib build are for multithreaded. So basically your app is linking in the single threaded libs, and Cpw is linking in the multithreaded ones, resulting in multiple definitions for some basic runtime functions.

To fix this, open up the Cpw project. From the VC++ menus select Project->Settings->C++ Tab->Category pulldown:Code Generation and change the "use runtime library" pulldown to "Debug Single Threaded" (or "Single Threaded" for release.) You'll have to change this for both release and debug builds. That should fix the problem.

Regards,
Jim




[This message has been edited by jmathies (edited 02-25-2002).]

jpummill
02-26-2002, 06:24 AM
Hi Jim,

I looked at my project settings, and noticed that they were already set to "Debug Single Threaded" for Debug mode, and "Single Threaded" for runtime.

I tried changing them to "Debug Multi Threaded", and "Multithreaded" to see what would happen and I am still getting the same compile error.

Any idea what else I might be doing wrong?

Thanks for the help,
John

jmathies
02-27-2002, 09:24 AM
Well you need to make sure every part of your project is using the same runtime libs.

There are three sets: single threaded, multithreaded static, and multithreaded dll.

I might not have communicated the default cpw settings correctly - the Cpw dll you can download uses the multithreaded dll libs. These are also used by the freetype library linked into the dll.

Here are the ms libs: you can find this info by searching the built-in msvc help for LIBCD.

Your link errors indicate your using two different types. Make sure these libs are synced, and make sure to clean / rebuild the project.

Single-threaded (libc.lib)
Multithreaded (libcmt.lib)
Multithreaded using DLL (msvcrt.lib)
Debug Single-threaded (libcd.lib)
Debug Multithreaded (libcmtd.lib)
Debug Multithreaded using DLL (msvcrtd.lib)

If you run into more trouble, mail me directly and I'll try to help you out.

Regards,
Jim