More linking problems with VC6!


#1

Hi,
I am having problems compiling a C++ program using the Front Panel API. I am using Visual C++ 6.0 and I have listed my steps here so that someone can point out where I’m going wrong.

  1. I load up VC6 and create a new Win32 Console Application (empty project)
  2. I copy into the working dir of the project “okCUsbFrontPanel.h” and “okFrontPanel-vc6.lib” from the installation driectory.
  3. I create the following source file (main.cpp)

#include “okCUsbFrontPanel.h”
int main() {
okCUsbXEM3001v2 xem;
return 0;
}

  1. Under Project|Settings|Link I add “okFrontPanel-vc6.lib” to the end of the ‘Object/Library Modules’ box.
  2. The project compiles ok but when linking the following errors appear.

MSVCRT.lib(MSVCRT.dll) : error LNK2005: __close already defined in LIBCD.lib(close.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __lseek already defined in LIBCD.lib(lseek.obj)
LINK : warning LNK4098: defaultlib “MSVCRT” conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib “LIBCMT” conflicts with use of other libs; use /NODEFAULTLIB:library
xemprog___Win32_Debug/xemprog.exe : fatal error LNK1169: one or more multiply defined symbols found

I’m not sure how to fix this, I have tried adding /NODEFAULTLIB:libcd to project options and this can sometimes remove the errors but as soon as I start to call methods in the driver they reappear and are even less comprehendable. What makes this worse is that I can get this all to work under Linux (Slackware 10) which I thought would be the much harder task!

Thanks
Ian Gray


#2

Hi Ian-

Try putting the NODEFAULT lib for “libcmt” and “msvcrt”.


#3

I’ve got the same problem at first. Try to add LIBC.lib in the ignore libraries. It’s in some settings for links I think.


#4

As a follow-on to this topic, here is a good link from the MSDN pages that describes the various libraries that Visual Studio uses. Depending on what 3rd-party libs you link against, this may help you better understand what’s going on:

http://msdn2.microsoft.com/library/abx4dbyh(en-us,vs.80).aspx


#5

error LNK2005:

To avoid this link error, change setting for [Project]-[Setting]-[C/C++],
Category -> Code Generation, Use run-time library to: Debug Multithreaded DLL

The default setting of ‘Use run-time labrary’ is ‘Debug Single-Threaded’, which is apparently incorrect…

This combined with the NODEFAULT lib for “libcmt” and “msvcrt” seems to work for me.


#6

Yes – if you are doing C++ development, you are encouraged to walk through the online tutorial accessible from the XEM3001 product page. Part 3 discusses the creation of a new project which makes use of the C++ API library.

The tutorial is written around the DES sample.


#7

I found that adjusting your project settings to MultiThreaded DLL removed all problems with linking.