User forums > Using Code::Blocks

Visual C++ 2005 Express linker issue

(1/3) > >>

bala_48225:
Hello, I do WinXP SP3, and I've just started trying the VC++ 2005 Express compiler (in CodeBlocks of cours) to compile some of my sdl programs.  I've looked around online including here, but have been unsuccessful in dealing with the following linker error somehow:

sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError|

there are 8 other ones including fgetc and fopen.  Here are the other facts:

In compiler settings:  checked "Multi-threaded dll debug runtime library"

In compiler settings -> Linker Settings ->

kernel32.lib
user32.lib
gdi32.lib

(also were some others which i took out to see what would happen and the error is the same)

In compiler settings -> Linker Settings -> Other Settings:

/NODEFAULTLIB:msvcrt
/SUBSYSTEM:CONSOLE

In compiler settings -> Search Directories I have the compiler, linker and resource directories copied with copy/paste, verbatim, to the

c:\...vc\include, \lib

and c:\...platform sdk\include, \lib also.

for some reason, I'm at a loss...so thanks in advance for any and all replies! -B

Alpha:
Does the standard "Hello world" program compile with your current setup?

--- Code: ---#include <iostream>

int main()
{
    std::cout << "Hello world";
    return 0;
}

--- End code ---

bala_48225:
yes it does, though it gives some warnings about exception handling:

C:\Program Files\Microsoft Visual C++ 2005 Express\VC\include\xlocnum|130|warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc|

that didn't happen with the sdl project and no biggie from where I'm sitting, but that's full disclosure.

Alpha:
OK - just testing for easy problems first (like improper compiler setup) :).

Have you tried using the Code::Blocks SDL project template?

The page Using SDL with Code::Blocks is for a different compiler (minGW), but you could check to see if there is something that is applicable to you.

Could you try compiling with full command line logging (when posting here, use code tags so that it is readable).



--- Quote from: bala_48225 on November 03, 2011, 02:16:17 am ---kernel32.lib
user32.lib
gdi32.lib

--- End quote ---
As a note, it is generally unnecessary to add the .lib file extensions (although it should not harm anything... I think).

bala_48225:
Here is the full command line log:


--- Code: ---||=== ExtraLife, Debug ===|
LINK||warning LNK4044: unrecognized option '/EHsc'; ignored|
sprig.lib(d000017.o)||warning LNK4078: multiple '.text' sections found with different attributes (E0300020)|
sdlmain.lib(SDL_win32_main.obj)||warning LNK4217: locally defined symbol _isspace imported in function _ParseCommandLine|
sdlmain.lib(SDL_win32_main.obj)||warning LNK4217: locally defined symbol ___iob_func imported in function _ShowError|
sdlmain.lib(SDL_win32_main.obj)||warning LNK4217: locally defined symbol _fclose imported in function _cleanup_output|
sdlmain.lib(SDL_win32_main.obj)||warning LNK4217: locally defined symbol _exit imported in function _main|
sdlmain.lib(SDL_win32_main.obj)||warning LNK4217: locally defined symbol _atoi imported in function _WinMain@16|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__fprintf referenced in function _ShowError|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__remove referenced in function _cleanup_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__fopen referenced in function _cleanup_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__fgetc referenced in function _cleanup_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__setbuf referenced in function _redirect_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__setvbuf referenced in function _redirect_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__freopen referenced in function _redirect_output|
sdlmain.lib(SDL_win32_main.obj)||error LNK2019: unresolved external symbol __imp__strrchr referenced in function _main|
bin\Debug\ExtraLife.exe||fatal error LNK1120: 8 unresolved externals|
||=== Build finished: 9 errors, 7 warnings ===|
--- End code ---

and btw, here are the linker settings for the project:

sdl.lib
sdlmain.lib
sprig.lib
 
I took the .lib extension off of them all (project and compiler settings), but the errors are the same.

Edit:  Unbelievable!  I added #include <cstdio> to the main.cpp file and it now links!  (fopen is in stdio.h), however it crashes once it runs.


Navigation

[0] Message Index

[#] Next page

Go to full version