1

I added c.obj from https://github.com/KxSystems/kdb/tree/master/w64 - #pragma comment(lib, "c.obj")

But I am getting this error

\3rdParty\kdb\c.obj : warning LNK4003: invalid library format; library ignored

5>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

error LNK2019: unresolved external symbol k referenced in function "public: virtual void __cdecl...

error LNK2019: unresolved external symbol ktd referenced in function "private: void __cdecl ...

error LNK2019: unresolved external symbol khpu referenced in function "private: void __cdecl ...

fatal error LNK1120: 3 unresolved externals

I have tried everything there in google but nothing seems to work.

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36

2 Answers2

0

#pragma comment lib doesn't accept object files, only libraries. I see that you have a c.lib file, and I assume that is the library file you need to include with pragma directive, so change it to #pragma comment( lib, "c.lib")

Cătălin Pitiș
  • 14,123
  • 2
  • 39
  • 62
  • I tried c.lib, then I get an error -> c.dll not found even though it is in the same folder as c.lib – user2256532 Aug 19 '13 at 08:31
  • You should check that c.dll is in a path that is configured for executable files (unfortunately I don't have visual studio to give you details). However, this path is different from the input library paths. – Cătălin Pitiș Aug 19 '13 at 10:23
0

In the Microsoft documentation it is said that :

#pragma comment( lib, "commenstring" )

lib

Places a library-search record in the object file. This comment type must be accompanied by a commentstring parameter containing the name (and possibly the path) of the library that you want the linker to search.

It searches for a library not an object file.

You should have a .lib file to include with this pragma directive.

It should be something like :

#pragma comment( lib, "c.lib" )
Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62
  • I tried c.lib, then I get an error -> c.dll not found even though it is in the same folder as c.lib – user2256532 Aug 19 '13 at 08:30
  • @user2256532 You get this error at the execution I suppose. Put c.dll inside your binary folder. – Pierre Fourgeaud Aug 19 '13 at 08:32
  • yes.. error is during execution.. where is binary folder? – user2256532 Aug 19 '13 at 08:33
  • @user2256532 You should have a `bin/Release` or `bin/Debug` in your project directory. If you are compiling in debug for example, just copy the `c.dll` inside `your_project_folder\bin\Debug` – Pierre Fourgeaud Aug 19 '13 at 08:36
  • Yeah this worked.. Thanks Is there any way to reference to some other folder? – user2256532 Aug 19 '13 at 08:39
  • @user2256532 Yes, if you want your `.dll` in another folder, you can change the `Path` environment variable. But you have to do it on every computer you test your program. You can do it with [Rapid Environment Editor](http://www.rapidee.com/en/about). – Pierre Fourgeaud Aug 19 '13 at 08:42