dynamic/static linking

2 posts / 0 new
Last post
Offline
Last seen: 11 years 3 weeks ago
Joined: 11/20/2012
Posts: 5
dynamic/static linking

I am trying to change my windows project from using dynamic linked libs to static libs. I have made what I thought was the necessary change to my project (adding a z to the end of the lib name) but now i am getting unresolved externals, e.g. __imp__ntohl. HELP, what have I missed.

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 5 hours ago
Joined: 06/02/2010
Posts: 601

Hi,

That symbol is in the library  WS2_32.lib which is part of the Windows operating system.  It looks like somehow it may no longer be in your link line? 

Is  __imp__ntohl  the only unresolved symbol you get?  If you are really not linking WS@_32.dll I would expect many other symbols to be unresolved, things like _imp__htonl, __imp__WSAGetLastError, __imp__WSAIoctl, etc.

You can take a look at the compiler and linker configuration properties and compare them with the ones that are recommended and generated with rtiddsgen when you specify a "Release" instead of a "Release DLL" configuration. If you use VusialStudio, the easiest way to look at them is to right click on the project and select "properties". On the popup select the "Command Line" option under both the "C/C++" entry and the "Linker" entry.

For your reference, these are the properties I have for Release with static linking:

C/C++ Compiling properties

/O2 /Ob1 /I "Z:\dom\apps_rti\RTI500_win32\ndds.5.0.0\include" /I "Z:\dom\apps_rti\RTI500_win32\ndds.5.0.0\include\ndds" /D "WIN32" /D "RTI_WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /GF /FD /EHsc /MT /Gy /Fo".\objs\i86Win32VS2008\\" /Fd".\objs\i86Win32VS2008\\" /W3 /nologo /c /errorReport:prompt

Linking Properties:

/OUT:".\objs\i86Win32VS2008\test_publisher.exe" /NOLOGO /LIBPATH:"Z:\dom\apps_rti\RTI500_win32\ndds.5.0.0\lib\i86Win32VS2008" /MANIFEST /MANIFESTFILE:".\objs\i86Win32VS2008\test_publisher.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:".\objs\i86Win32VS2008\test_publisher.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT nddscppz.lib nddscz.lib nddscorez.lib netapi32.lib advapi32.lib user32.lib WS2_32.lib   kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

See figure:

Visual Studio 2008 Screeenshot