cancel
Showing results for 
Search instead for 
Did you mean: 

Linking to c.obj in Visual Studio 2010

yzhao0527
New Contributor
I initiated this question in a separated post : https://groups.google.com/d/topic/personal-kdbplus/sGTaB0rVRjk/discussion

but got really frustrated with Visual Studio 2010. My goal is to write a tool like the Studio for KDB+ so others can use it without dealing with c.dll and setting environmental variables.

My code is very simple:

//--------------------------BEGIN------------------------------------------------
#define KXVER 3
#include "k.h"

int main(int argc, char *argv[]) {
    int handle;
    handle=khpu("localhost",5000,"username:password");

    return 0;
}
//--------------------------END------------------------------------------------

I did the following to build the program in Visual studio 2010.

1. right click solutions -> properties -> Configuration Properties -> VC++ Directories : I modified Include Directory and Library Directory
2. right click solutions -> properties -> Configuration Properties -> Linker -> Input: I added c.obj to Additional Dependencies.

However, the code fails with the following Error Message:

1>------ Build started: Project: demo_kdb, Configuration: Debug Win32 ------
1>Build started 1/24/2013 6:43:14 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\demo_kdb.unsuccessfulbuild".
1>ClCompile:
1>  connect.cpp
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>c.obj : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _cls
1>c.obj : error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function _snb
1>c.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _wsa
1>c.obj : error LNK2019: unresolved external symbol __imp__gethostbyaddr@12 referenced in function _hl
1>c.obj : error LNK2019: unresolved external symbol __imp__htonl@4 referenced in function _hl
1>c.obj : error LNK2019: unresolved external symbol __imp__ntohl@4 referenced in function _addr
1>c.obj : error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function _addr
1>c.obj : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function _addr
1>c.obj : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function _accp
1>c.obj : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function _cb
1>c.obj : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function _cb
1>c.obj : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function _cb
1>c.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _cb
1>c.obj : error LNK2019: unresolved external symbol __imp__setsockopt@20 referenced in function _sopt
1>c.obj : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function _lstn
1>c.obj : error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _pod
1>c.obj : error LNK2019: unresolved external symbol __imp__getsockname@12 referenced in function _pod
1>c.obj : error LNK2019: unresolved external symbol __imp__getsockopt@20 referenced in function _apu
1>c.obj : error LNK2019: unresolved external symbol __imp__select@20 referenced in function _apu
1>c.obj : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _rcv
1>c.obj : error LNK2019: unresolved external symbol __imp__send@16 referenced in function _snd
1>c:\xxx\demo_kdb.exe : fatal error LNK1120: 21 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.60
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I don't know what's wrong. If I use c.lib instead of c.obj, the code got compiled successfully, but it would require c.dll to run. Some one kindly suggested me to include /NODEFAULTLIB:MSVCRTD as the linker option, but this only caused other trouble.

I would be greatly appreciative if you can help me out ...

... and ... thanks for your time reading my post, even if you couldn't offer help 🙂

Best Regards,
0 REPLIES 0