Author Topic: Issues in importing a MS Visual C++ .NET 2003 solution  (Read 18913 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...

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #15 on: August 10, 2005, 09:17:32 pm »
Ok, I see. Thanks for the explanation. Personally, I have always installed MS Visual Studio .NET 2002 and later 2003, so I could not really notice it.

Anyway, let me congratulate again for the good job you are doing with CodeBlocks  :D and I hope that you will continue in the future. Until now it is the best alternative after MS Visual Studio .NET 2003.

Best wishes,
Michael

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #16 on: October 19, 2005, 06:31:36 pm »
Iīm still having the problem:
error LNK2019: unresolved external symbol __ftol2

Iīve proved to put the next lines of code in my c file:

#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

but now the problem is the string "C", it isnīt recognized by the compiler maybe. Iīve installed the microsotf c++ 2003 toolkit.
I donīt understand.

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #17 on: October 19, 2005, 07:26:04 pm »
Iīm still having the problem:
error LNK2019: unresolved external symbol __ftol2

Iīve proved to put the next lines of code in my c file:

#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

but now the problem is the string "C", it isnīt recognized by the compiler maybe. Iīve installed the microsotf c++ 2003 toolkit.
I donīt understand.

It should be, unless you're not compiling it as C++. (note: C doesn't support extern "<language>" declarations, that's a C++ addition)
If you're trying to compile it as both C and C++, try something this:
Code: [Select]
#if (_MSC_VER >= 1300) && (WINVER < 0x0500)
#ifdef __cplusplus
extern "C" {
#endif
//VC7 or later, building with pre-VC7 runtime libraries
long _ftol( double ); //defined by VC6 C libs
long _ftol2( double dblSource ) { return _ftol( dblSource ); }
#ifdef __cplusplus
} // extern "C"
#endif
#endif

or this:

Code: [Select]
#ifdef __cplusplus
  #define EXTERN_C extern "C"
#else
  #define EXTERN_C
#endif // __cplusplus

#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

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #18 on: October 20, 2005, 09:23:49 am »
No, those possible solutions donīt work. The message is the next:

error LNK2001: unresolved external symbol __ftol@8
error LNK2001: unresolved external symbol __ftol2

I donīt know what to do because I need solve this problem to continue my program! :,(

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #19 on: October 20, 2005, 08:33:37 pm »
it seems you forgot to add a library to the link libraries list in your project. You need to find out which VC6 library has these contained in, and link it.

Code::Blocks does NOT add the libraries for you! You need to figure them out on your own.

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #20 on: October 21, 2005, 01:01:34 am »
I know a library is needed but what?
In my link tab I have a lot of libraries, but I donīt know what is the one I need exactly.
Iīve proved with libc.lib, libcd.lib, but the problem continues.
Somebody know what is?

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #21 on: October 21, 2005, 01:45:02 am »
Hmmmmmmmmm. Perhaps some of the options got lost... try converting your solution to a Visual C++ 6 workspace, and then import. Does it work?

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #22 on: October 21, 2005, 12:04:55 pm »
I comment my problem from the begining:

I have some .c, .h and .f (fortran) files. I need to create a dll with them. For it, I use the compaq visual fortran profeesional 6.5 because I have .f files (fortran). All the files compile perfectly. But the problem is linking.

Iīve downloaded the microsoft c++ toolkit for the compiler in c.

I donīt change to visual c++ 6 because it doesnīt compile fortran files, and I need them. I need to create a dll, and it is possible with compaq visual fortran.

The problem continues... :

CCFD.obj : error LNK2001: unresolved external symbol __ftol@8
MF2KGMG.obj : error LNK2001: unresolved external symbol __ftol2
SOLVERS.obj : error LNK2001: unresolved external symbol __ftol2

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #23 on: October 21, 2005, 12:33:20 pm »
...The problem continues... :
CCFD.obj : error LNK2001: unresolved external symbol __ftol@8
MF2KGMG.obj : error LNK2001: unresolved external symbol __ftol2
SOLVERS.obj : error LNK2001: unresolved external symbol __ftol2
try linking with
Code: [Select]
msvcrt.lib and be sure ,that you compile in "C" mode

or mind posting your complete project here,
because soothsaying is quite hard...

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #24 on: October 21, 2005, 12:35:44 pm »
Hello,

I am not sure how you try to put together .c, .h and .f files. Anyway, you can try to download (if not yet done) the Microsoft Platform SDK and to add to CB the corresponding include and lib directories.

May be you can also try to google your problem. Sometimes you get useful links or informations to what to do.

Best wishes,
Michael

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #25 on: October 21, 2005, 01:14:18 pm »
The libraries that Iīve included are:

kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib msvcrt.lib libc.lib gmg1_2.lib

Already Iīve included msvcrt.lib like you can see.


Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #26 on: October 21, 2005, 01:34:06 pm »
Hello,

Then, as suggested by Tiwag, try to post your project. It would be easier to detect what it is wrong.

Best wishes,
Michael

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #27 on: October 21, 2005, 05:21:46 pm »
What i mean with converting to MSVC workspace, was that you should grab the Solution and convert it - i think there was a project converter tool, i don't remember exactly. But I recall from elsewhere in the forums that C::B has a problem with importing some MSVC solutions.

Offline alixia

  • Single posting newcomer
  • *
  • Posts: 6
Re: Issues in importing a MS Visual C++ .NET 2003 solution
« Reply #28 on: October 22, 2005, 12:22:11 pm »
My problem was resolved!!!
In my settings I had the option "Not using MFC" and I changed this.