1

I am compiling my project in the release mode in VC++. I have a .def file where i have declared the setLog and now i am getting following error

Linking... Creating library Release/HKL.lib and object Release/HKL.exp HKL_libinterface.obj : error LNK2001: unresolved external symbol _SCTP_setLog@8

Please help me on the above to fix the problem.

Thanks

BIBD
  • 15,107
  • 25
  • 85
  • 137

3 Answers3

2

It sounds to me like you have a lib file configured in your debug build that is not in the release build. Your setLog() function does not seem to be the function the linker is complaining about - it sounds like it's not finding a function called SCTP_setLog().

Look in the list of libraries you have configured in your project's debug configuration and make sure they are also configured in the release configuration.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • This is the most likely case. Visual Studio makes you set every build option twice--once in Debug and once in Release--just in case you want them to be different (which sometimes, you do). – i_am_jorf Mar 14 '09 at 06:16
  • You *can* set both at once, but you have to remember that *before* you actually set the option :) – Thomas Mar 14 '09 at 06:54
0

If this compiles in Debug mode the most possible reason is that somehow the code where this function is implemented is not included into build - for example, the cpp file where it is implemented has "Excluded from build" set.

sharptooth
  • 167,383
  • 100
  • 513
  • 979
  • Yes it compiles fine in the debug mode.. How to include a cpp file into the build set.. plz tell me how.. Thanks –  Mar 13 '09 at 10:24
  • You add it to the project tree in Solution Explorer. I guess you already have it added. Then you right-click, select "Properties" and check what's on the General tab. "Excluded form build" should be "No". – sharptooth Mar 13 '09 at 10:28
  • I see a checkbox for "Excluded form build" in the General tab where for all the cpp files this "Excluded form build" is unchecked (I guess it is NO). But then also i m facing the same error. –  Mar 13 '09 at 10:36
  • Okay. What is the setLog function definition? Is it in a .cpp or .h file? – sharptooth Mar 13 '09 at 10:47
  • it is a API exposed to the VB application. It is declared in the log.h file and defined in log.cpp –  Mar 13 '09 at 10:48
  • What is the complete declaration? I mean the "int setLog()" line. Also what is the corresponding line in the def file? – sharptooth Mar 13 '09 at 10:59
  • This is the declaration in the .h file: extern "C" int __stdcall setLog(log_type logType, bool isLog); This is defined in the .cpp file. The corresponding line in the def file is setLog @10 –  Mar 13 '09 at 11:18
  • What if you replace @10 with PRIVATE? – sharptooth Mar 13 '09 at 11:21
  • No it does not help..i m still facing the same error. And i can not replace @10 with PRIVATE since this API is exposed to the VB application. Please suggest me what to do.. –  Mar 13 '09 at 12:04
  • I did similar in my code and it works. Let's dig further. What is the function declaration in cpp? I mean the definition without the actual implementation. – sharptooth Mar 13 '09 at 12:43
  • In .cpp file it is declared as below: extern "C" int __stdcall setLog(log_type logType, bool isLog) { return LOGAPPCALLBACK()->openFile(logType, isLog); } –  Mar 13 '09 at 13:29
0

As sharptooth mentioned, you most likely are not compiling the above function in your release build. In addition to looking for 'Excluded from build', check if you have any defines set (or not set) that would exclude the missing function from your release build.

Aaron Saarela
  • 3,956
  • 1
  • 19
  • 17
  • Hi can you please explain me in detail where and how to check this.. :( i m new to this –  Mar 13 '09 at 12:18