• 13
• 15
• 27
• 9
• 9

# C++ compiler advice

This topic is 3969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm having a lot of trouble with compilers, and even more with linking, at the moment. I'm asking for a bit of advice both regarding which compiler to get, and general stuff about linking etc. 1. how do I typically link libraries? From what I understand, I need to put all .lib files in the special directories known by the compiler as library directiories, and all .h files in special directories known by the compiler as include file directories. I may also put the files in subfolders in the include directory, such as INCLUDE_DIRECTORY\mylib\, in which case I include the file by: #include <mylib/file.h> rather than: #include <file.h>. I assume that I must then also put the .lib files in LIBRARY_DIRECTORY\mylib\ in a corresponding way when I put the include files in a subdirectory. All .dll files should go in C:\windows\system. When I create a project, I don't need to add any files to the project/solution in VC express, but simply write lines such as: #include <file.h> in my .h and .cpp files and everything will work. Is this correct, or am I forgetting something? 2. what does VC express lack, that the full version of VC has? Is there any reason I shouldn't use VC express as my compiler, and uninstall VC6 full version, or should I instead get DevC++, GNU compiler or any other competing compiler? I will probably need to use the DirectX SDK, SDL and a few other libraries and want them to work with the compiler. 3. from what I've understood, the platform sdk is necessary to be able to compile any windows related stuff with VC express. I think I've got a 64 bit CPU, but a 32 bit version of windows xp installed. Should I then get the 32 bit or 64 bit version of the platform sdk? 4. if I settle with VC express 2005, do I need to reinstall dx sdk and platform sdk over it to get it to work? 5. can my keeping VC6 installed before installing VC express interfere with my VC express installation?

##### Share on other sites
Quote:
 Original post by all_names_takenIs this correct, or am I forgetting something?

You need to explicitly link to the libraries. In Visual Studio: Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies

Add your libs there seperated with a blank space, i.e: d3d9.lib d3dx9.lib User32.lib kernel32.lib

Quote:
 Original post by all_names_taken2. what does VC express lack, that the full version of VC has?

Product Feature Comparisons

Quote:
 Original post by all_names_takenIs there any reason I shouldn't use VC express as my compiler, and uninstall VC6 full version, or should I instead get DevC++, GNU compiler or any other competing compiler? I will probably need to use the DirectX SDK, SDL and a few other libraries and want them to work with the compiler.

There is no reason not to use VC Express. I believe most people here will agree that it is the best free IDE around. VC6 is obsolete, and there really is no reason to use DevC++ since it's inferior to VS.

Quote:
 Original post by all_names_taken3. from what I've understood, the platform sdk is necessary to be able to compile any windows related stuff with VC express. I think I've got a 64 bit CPU, but a 32 bit version of windows xp installed. Should I then get the 32 bit or 64 bit version of the platform sdk?

I would guess that your platform needs to be 64-bit since it's the platform SDK.

Quote:
 Original post by all_names_taken4. if I settle with VC express 2005, do I need to reinstall dx sdk and platform sdk over it to get it to work?

Hmm, not sure about this. You might have re-install DX SDK unless you want to manually set directories and add wizards, but I'm not sure about this, so someone else has to answer that.

Quote:
 Original post by all_names_taken5. can my keeping VC6 installed before installing VC express interfere with my VC express installation?

Yes you can have both at the same time, although as stated above VC6 is terrible! There are several compiler bugs and it's too far off the C++ Standard to be useful.

##### Share on other sites
Quote:
 Original post by all_names_taken1. how do I typically link libraries? From what I understand, I need to put all .lib files in the special directories known by the compiler as library directiories, and all .h files in special directories known by the compiler as include file directories.

Putting them on the known directories is not enough to link against libraries.
You have to specify which one of them are you going to use. In the Porject propierties tab (Alt+F7) Go to Configuration Propierties->Linker->Input
and write the libs you need in the "Additional Propierties" edit box. Usually you would write kernel32.lib user32.lib gdi32.lib advapi32.lib (and d3d9.lib for D3D 9, etc)
Look in the Platform SDK's Doc to find which lib you need for specific features.
There are also other not recommended ways to link against a lib (like adding the lib to the project like you would do with a cpp file)

Quote:
 I may also put the files in subfolders in the include directory, such as INCLUDE_DIRECTORY\mylib\, in which case I include the file by: #include rather than: #include

Right

Quote:
 2. what does VC express lack, that the full version of VC has? Is there any reason I shouldn't use VC express as my compiler, and uninstall VC6 full version, or should I instead get DevC++, GNU compiler or any other competing compiler? I will probably need to use the DirectX SDK, SDL and a few other libraries and want them to work with the compiler.

VC is the best for DirectX SDK, because they're both thought by MS. VC Express lacks of resource editor (used to simplify (a lot) the creation of GDI GUIs)
VC express can compile resources (with the plattform I think) but you can't edit them.
VC6 is faster for slower computers, but also compiles the code worse, and makes it slower than VC 2005 (not always)

Quote:
 3. from what I've understood, the platform sdk is necessary to be able to compile any windows related stuff with VC express. I think I've got a 64 bit CPU, but a 32 bit version of windows xp installed. Should I then get the 32 bit or 64 bit version of the platform sdk?

Not strictly necessary. But any decent app should need the Platform. If you're using a Win XP 32-bit, then use Plat. SDK for 32-bit; it can still build x64 application but you won't be able to test them unless you use Win XP x64.
Also... 64-bit of the Plat sdk?? I don't remember it. May be you're confusing with the IA64 version. IA64 & x64 just share the "64" number, but they're completely different, IA64 will NEVER work on your computer (unless, you're using an Itanium Emulator, if exists ;)

Quote:
 4. if I settle with VC express 2005, do I need to reinstall dx sdk and platform sdk over it to get it to work?

No. Just set the right paths in the VC express 2005 to your Plat SDK include and libs folders.

Quote:
 5. can my keeping VC6 installed before installing VC express interfere with my VC express installation?

I've tried, and didn't seem to make any problem. But who knows...

Hope it helps
Dark Sylinc

##### Share on other sites
Thanks for your help, it seems VC express is the way to go then. I got rid of most build errors now, but there's still one error/warning problem left. When I try to build the following project:

#include <SDL/SDL.h>int main(int argc, char *argv) {	return 0;}

I get this error:

------ Rebuild All started: Project: SDL1, Configuration: Debug Win32 ------Deleting intermediate and output files for project 'SDL1', configuration 'Debug|Win32'Compiling...main.cppCompiling manifest to resources...Linking...MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:librarysdlmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _mainC:\Documents and Settings\Myself\My Documents\Visual Studio 2005\Projects\SDL1\Debug\SDL1.exe : fatal error LNK1120: 1 unresolved externalsBuild log was saved at "file://c:\Documents and Settings\Myself\My Documents\Visual Studio 2005\Projects\SDL1\SDL1\Debug\BuildLog.htm"SDL1 - 2 error(s), 1 warning(s)========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

When I try to build this program:

#include <stdlib.h>#include <SDL/SDL.h>int main(int argc, char *argv[]) {	return 0;}

I don't get any error, but I still get a warning similar to the previous error message:

------ Rebuild All started: Project: SDL1, Configuration: Debug Win32 ------Deleting intermediate and output files for project 'SDL1', configuration 'Debug|Win32'Compiling...main.cppCompiling manifest to resources...Linking...LINK : C:\Documents and Settings\Myself\My Documents\Visual Studio 2005\Projects\SDL1\Debug\SDL1.exe not found or not built by the last incremental link; performing full linkMSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:libraryEmbedding manifest...Build log was saved at "file://c:\Documents and Settings\Myself\My Documents\Visual Studio 2005\Projects\SDL1\SDL1\Debug\BuildLog.htm"SDL1 - 0 error(s), 1 warning(s)========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

My conclusion, which is just a guess, is that I have to include stdlib before sdl or I get an error. Is this correct? But even when I do this, something still seems to be wrong with msvcrt.lib. How can I solve this, or is this an error that doesn't matter?

##### Share on other sites
Your first posted program is missing the [] after argv, which causes it to have a different signature than the one SDL wants.

Also, as far as the warning, in your project settings in "Configuration Properties->Linker->Input" try adding msvcrt.lib to "Ignore Specific Library"