Author Topic: Issues in importing a MS Visual C++ .NET 2003 solution  (Read 18392 times)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Issues in importing a MS Visual C++ .NET 2003 solution
« on: August 08, 2005, 12:24:54 pm »
Dear all,

I have tried to import the solution (MS Visual C++ .NET 2003) for the RakNet project and generally it works quite good. Anyway, there was issues that needed to be fixed to make CodeBlocks compiles the different projects.

First of all let me say that I have download the latest version of Codeblocks (patch). A first remark is that CodeBlocks still displays 1.0-RC1 and not 1.0-RC1-1. Is this normal?

Then I have set the Codeblocks to works with MS Visual C++ .NET 2003 compiler (free Toolkit) as default and set the necessary pathes. Anyway, where I have to set the bin pathes? In .NET there is an "Executables" folder where you can add bin pathes, but for CodeBlocks :?? Is may be the "resources" folder?

Finally, I have tried to compile to the different projects, one after the other. But here a first issue. The link directories and libraries were not imported correctly. For example, there was missing the extension ".lib", which made CodeBlocks search for a .obj file instead of a .lib. Fixed this problem, I could compile the projects. To be sure or quite that it was a problem (or a bad setting) of CodeBlocks, I have tried to compile each project with MS Visual C++ .NET 2003.

I have remarked the following:

(1) Some projects compile only under "release", but give a link error(s) under "debug". Strange  :?.
(2) Some projects refuse to compile in both "debug" and "release" (e.g., DLL). Mostly due to link errors.
(3) Some projects compile just fine :).

Are the above mentioned problems related to the import functionality of CodeBlocks (not yet finished), or I missed something?

Any idea, comment, help is highly appreciated.

Anyway, let me congratulate for the good work you are doing and hope you will continue improving CodeBlocks in the future.

Best wishes,
Michael

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #1 on: August 08, 2005, 01:26:58 pm »
Then I have set the Codeblocks to works with MS Visual C++ .NET 2003 compiler (free Toolkit) as default and set the necessary pathes. Anyway, where I have to set the bin pathes? In .NET there is an "Executables" folder where you can add bin pathes, but for CodeBlocks :?? Is may be the "resources" folder?
C::B looks for executables either in "bin" subdirectory of Compiler's installation directory or any of "Extra paths". Both can be set under "Settings->Compiler->Programs".

Quote
(1) Some projects compile only under "release", but give a link error(s) under "debug". Strange  Confused.
(2) Some projects refuse to compile in both "debug" and "release" (e.g., DLL). Mostly due to link errors.
Do they require resource compiler? If yes, don't forget there's no resource compiler in basic VC Toolkit 2003 bundle, you have to install Platform SDK to get one. (you will have to add Extra path to Platform SDK's "bin" directory or copy 'rc.exe' into VC Toolkit's "bin")
« Last Edit: August 08, 2005, 01:28:37 pm by squizzz »
this space is for rent

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #2 on: August 08, 2005, 02:36:28 pm »
Hello,

Thank you very much for the help.

I have already Microsoft Platform SDK installed (latest version). As you told me, I put the bin pathes to their right places (plus the RC.Exe and Cvtres.exe in the compiler bin folder) and now I can compile some more projects. Unfortunately, I still have problems to compile some projects under debug. Under release they compile just fine, but under debug they refuse to compile (link error(s). And quite strange one(s)).

The setting are the same for both release and debug and only changes some libraries. Very strange... :?.

Best wishes,
Michael
« Last Edit: April 24, 2006, 11:52:41 am by Michael »

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #3 on: August 08, 2005, 11:13:27 pm »
Under release they compile just fine, but under debug they refuse to compile (link error(s). And quite strange one(s)).
Could you post these errors, please?
Also tell (or post screenshots) what libraries you link to release version (which compiles succesfully) and debug version (which fails). Right click project, then "Build options", then "Linker options" tab.


Also, go to "Settings->Compiler" and click directories tab - do you have correct paths to Platform SDK "include" (compiler) and "lib" (linker) there? (C::B doesn't detect platform SDK installation...). Do you have resource compiler directory set under the last tab? Please check these ones.
this space is for rent

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #4 on: August 09, 2005, 12:16:40 pm »
Hello,

I have checked the MS Platform SDK directories and despite the resource one, all are set correctly (if not I could not compile).

After adding the resource directory (which point to the C:\Programme\Microsoft Visual C++ Toolkit 2003\bin where the RC.Exe is), I have tried to re-compile a DLL project, but still getting link errors under debug. Here are the errors:

--------------------------------------------------------------------------------
Project   : RakVoiceDLL
Compiler  : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\Dokumente und Einstellungen\zum\Eigene Dateien\CodeBlocks_Projects\RakNetRakNet_v2.332\Lib\RakVoiceDLL\
--------------------------------------------------------------------------------
Switching to target: Debug
Linking dynamic library: Debug\..\..\RakVoiceDebug.dll
   Creating library Debug\..\..\RakVoiceDebug.lib and object Debug\..\..\RakVoiceDebug.exp
denoise.obj : error LNK2019: unresolved external symbol __ftol2 referenced in function _speex_preprocess
nb_celp.obj : error LNK2001: unresolved external symbol __ftol2
sb_celp.obj : error LNK2001: unresolved external symbol __ftol2
stereo.obj : error LNK2001: unresolved external symbol __ftol2
Debug\..\..\RakVoiceDebug.dll : fatal error LNK1120: 1 unresolved externals
Process terminated with status 1 (0 minutes, 5 seconds)
5 errors, 0 warnings
--------------------------------------------------------------------------------

Under release the compilation and linking was fine.

Concerning the libraries here they are:

Debug:
---------
Link libraries:
RakNetLibStaticDebug.lib
Other linker options:
/debug
/pdb:Debug\RakVoiceDLL.pdb

Release:
---------
Link libraries:
RakNetLibStatic.lib
Other linker options:
/debug
/INCREMENTAL:NO

Another project that fails under debug, but not under release is this one:

--------------------------------------------------------------------------------
Project   : Chat Example Server
Compiler  : Microsoft Visual C++ Toolkit 2003 (called directly)
Directory : C:\Dokumente und Einstellungen\zum\Eigene Dateien\CodeBlocks_Projects\RakNetRakNet_v2.332\Samples\Code Samples\Chat Example\
--------------------------------------------------------------------------------
Switching to target: Debug
Linking console executable: Debug\Chat Example Server.exe
LINK : fatal error LNK1104: cannot open file 'Example.obj'
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
--------------------------------------------------------------------------------

Concerning the libraries here they are:

Debug:
---------
Link libraries:
RakNetLibStaticDebug.lib
ws2_32.lib
Other linker options:
/debug
/pdb:Debug\Chat Example Server.pdb

Release:
---------
Link libraries:
RakNetLibStatic.lib
ws2_32.lib
Other linker options:
/debug
/INCREMENTAL:NO


The path of the directory to the libraries is the same for both release and debug.

I hope these small report could be of some help to detect the problem I have.

Could may be related to the "Other linker options"?

Thank you very much.

Best wishes,
Michael

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #5 on: August 09, 2005, 02:50:27 pm »
I googled few links that refer to VC Toolkit and "unresolved external symbol __ftol2".

Q: http://www.mico.org/pipermail/mico-devel/2004-September/008968.html
A: http://www.mico.org/pipermail/mico-devel/2004-September/008970.html

http://www.relisoft.com/forum/toast.asp?sub=show&action=posts&fid=5&tid=2542

This might be msvcrt.lib issue suggested there. There are also some compiler switches mentioned as well as Toolkit's limitations - you have to check it yourself whether they apply to your projects. (personally I don't use VCToolkit at all, just have it installed :) )

Quote
After adding the resource directory (which point to the C:\Programme\Microsoft Visual C++ Toolkit 2003\bin where the RC.Exe is)
It doesn't seem to be related to your problem, but - it should point to Platform SDK "include" path.

this space is for rent

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #6 on: August 09, 2005, 05:57:59 pm »
Hello,

Thank you very much for your help.

Concerning the __ftol2 symbol the solution is to add this code (see http://www.manusoft.com/Resources/ARXTips/Main.stm) :):

#if (_MSC_VER >= 1300) && (WINVER < 0x0500)
//VC7 or later, building with pre-VC7 runtime libraries
extern "C" long _ftol( double ); //defined by VC6 C libs
extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); }
#endif

I have also tried to add to the lib directory of the free toolkit the msvcrt.lib and msvcrtd.lib, but without solution.

Anyway, this does not solve my problem with the other project, the one that display a link error to an .obj file.

It is very strange that it compile under release, but not under debug. Really strange :? :?. I will have to look at it more in depth when I will have some more free time.

Best wishes,
Michael

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #7 on: August 09, 2005, 06:23:47 pm »
My guess is that under debug you have to link to ANOTHER additional library (ahh... don't you love Microsoft's proprietary approaches?). But then again, we'd need an expert to tell us about it.

Hmmm Example.obj... perhaps MSVC expects to find a ".obj" instead a ".o" (which is what codeblocks uses, i think)... but I'm not sure, i'm a newbie in this.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #8 on: August 09, 2005, 06:38:41 pm »
To be honest, I do not really like Microsoft proprietary approach. It just complicate the life of developers, users and so on.

Concerning the "Chat Example Server" Project, the funny thing is that I do not have a Example src file (.c or .cpp), but just a "Chat Example Server.cpp".

Well, I suppose that digging a bit more in the free toolkit limitations and to carefully compare the .NET 2003 implementation, this will lead to a solution. Well, I hope at least.

Best wishes,
Michael

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #9 on: August 09, 2005, 07:08:40 pm »
Concerning the "Chat Example Server" Project, the funny thing is that I do not have a Example src file (.c or .cpp), but just a "Chat Example Server.cpp".

Uh oh.... Houston, we have a space problem...

perhaps it tries to find "chat.obj", "example.obj" and "server.obj". Would you mind renaming that to "Chat something.cpp" and see if it tries to find something.obj?

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #10 on: August 09, 2005, 09:15:36 pm »
have you tried adding msvcrt.lib to the release build
and msvcrtd.lib to the debug build?

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #11 on: August 09, 2005, 09:49:22 pm »
OK, I actually downloaded the GNU RakNet source.  The example you gave, RakVoiceDLL, links to libcmt which is an MS lib.  The release version finds C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib\libcmt.lib.
***The Toolkit does not come with debugging libraries***
Download the .NET 1.1 SDK.  This will get you C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\libcmtd.lib
Then just add to project->build options->directories->linker:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib

Should compile fine then.

Btw, the import support is surprisingly complete.  I can see codeproject type guys liking CB because of this.  Real easy to check out other people's source (as MSVC targets are obviously the most common c++ projects/workspaces out there).

-----

Updated the wiki with some hints for VC++ toolkit:

http://wiki.codeblocks.org/index.php/Integrating_Microsoft_Visual_Toolkit_2003_with_Code::Blocks_IDE#Compiling_Hints

(feel free to modify if you want to reword or reformat better)
« Last Edit: August 09, 2005, 10:01:15 pm by grv575 »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #12 on: August 10, 2005, 11:53:53 am »
Dear all,

Thank you very much for your answers and help.

The problem I have had with the "Chat Example Server" Project was due to an option in "Other Linker options" and specifically to this one:

/pdb:Debug\Chat Example Server.pdb

After removing it, the project compiles fine under debug. This option was set by the import functionality of CodeBlocks.

Regarding the RakVoiceDLL, grv575 was right. After setting the path to C:\Programme\Microsoft Visual Studio .NET 2003\Vc7\lib, RakVoiceDLL compiled fine without the need for the additional code I have put in one of my previous answer.

Anyway, I would like to ask, thedirectory C:\Programme\Microsoft Visual Studio .NET 2003\Vc7\lib point not to MS Visual . NET 2003 C++? Why do you said that it belong to  .NET 1.1 SDK? In my computer  .NET 1.1 SDK is here:

C:\Programme\Microsoft Visual Studio .NET 2003\SDK

Thank you very much.

Best wishes,
Michael

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #13 on: August 10, 2005, 07:10:12 pm »
zieQ, your cue (Q :lol: )

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #14 on: August 10, 2005, 08:42:20 pm »
yeah the .net sdk installs both those directories (unless you already have VS probably).  confusing but i guess they want the path to the C libs in the same place always...