🔒 Locked
why always problems with iostream?
Advertisement
Original Post
Level: beginner IDE: VC++ 6.0 Problem: when adding #include using namespace std to a stupid program that does almost nothing (I am just trying to test what is wrong with iostream) I get: libcp.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __pctype libcp.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol _errno libcp.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol ___mb_cur_max libcp.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol ___lc_codepage libcp.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol ___lc_handle Release/code71.exe : fatal error LNK1120: 5 unresolved externals Error executing link.exe. as soon as you remove the include the linker seems happy... these are my linker settings: comctl32.lib wsock32.lib opengl32.lib glut32.lib glu32.lib fltk.lib fltkgl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /pdb:"Release/code71.pdb" /machine:I386 /nodefaultlib:"libc" /out:"Release/code71.exe" BTW, these settings are fine with other code that I have written. The question NOW is only about iostream: what is it there that I need to know?
/nodefaultlib:"libc" --> There's the problem
Quote:
/nodefaultlib:"libc" --> There's the problem
and why is so? is iostream inside libc.lib?
I thought the problem was there too, so I have already tried to remove it (honestly I don't even remember why i had it like that... probably to have FLTK working properly???)
and I get:
Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _tolower already defined in LIBC.lib(tolower.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in LIBC.lib(memmove.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in LIBC.lib(malloc.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _realloc already defined in LIBC.lib(realloc.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in LIBC.lib(free.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in LIBC.lib(sprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in LIBC.lib(fclose.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fwrite already defined in LIBC.lib(fwrite.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _exit already defined in LIBC.lib(crt0dat.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
Release/code71.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe
and reading these errors I see that msvcrt (what the heck is that?) is giving me the problems now...
Then you will probabally need to change the project RunTime library from Single Threaded to MultiThreaded or MultiThreaded DLL. That's what those errors mean most of the time - incompatible runtime settings between the libs. Also make sure you are not using #pragma comment to link in libs.
Quote:
Original post by Drew_Benton
Then you will probabally need to change the project RunTime library from Single Threaded to MultiThreaded or MultiThreaded DLL. That's what those errors mean most of the time - incompatible runtime settings between the libs. Also make sure you are not using #pragma comment to link in libs.
see? the problem is that i don't understand what i am doing wrong... this time i tried blocking the msvcrt.lib and i get A LOT of errors:
Linking...
LINK : warning LNK4049: locally defined symbol "_tolower" imported
LINK : warning LNK4049: locally defined symbol "_memmove" imported
LINK : warning LNK4049: locally defined symbol "_malloc" imported
LINK : warning LNK4049: locally defined symbol "_realloc" imported
LINK : warning LNK4049: locally defined symbol "_free" imported
LINK : warning LNK4049: locally defined symbol "_sprintf" imported
LINK : warning LNK4049: locally defined symbol "_fclose" imported
LINK : warning LNK4049: locally defined symbol "_fwrite" imported
LINK : warning LNK4049: locally defined symbol "_exit" imported
fltk.lib(Fl.obj) : error LNK2001: unresolved external symbol __imp__toupper
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__toupper
fltk.lib(Fl.obj) : error LNK2001: unresolved external symbol __imp__isupper
fltk.lib(Fl.obj) : error LNK2001: unresolved external symbol __imp__isalpha
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(fl_draw.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(Fl_Pixmap.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(Fl_Text_Display.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(fl_draw_pixmap.obj) : error LNK2001: unresolved external symbol __imp__isspace
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__strchr
fltk.lib(Fl_Input.obj) : error LNK2001: unresolved external symbol __imp__strchr
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__isalnum
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__isalnum
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__isdigit
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__isxdigit
fltk.lib(Fl_Input_.obj) : error LNK2001: unresolved external symbol __imp__strncmp
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__strncmp
fltk.lib(Fl_Pixmap.obj) : error LNK2001: unresolved external symbol __imp__sscanf
fltk.lib(Fl_get_system_colors.obj) : error LNK2001: unresolved external symbol __imp__sscanf
fltk.lib(fl_draw_pixmap.obj) : error LNK2001: unresolved external symbol __imp__sscanf
fltk.lib(Fl_Text_Display.obj) : error LNK2001: unresolved external symbol __imp__ispunct
fltk.lib(Fl_get_system_colors.obj) : error LNK2001: unresolved external symbol __imp__putenv
OLDNAMES.lib(putenv.obi) : error LNK2001: unresolved external symbol __imp__putenv
fltk.lib(Fl_get_system_colors.obj) : error LNK2001: unresolved external symbol __imp__strdup
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__strdup
OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup
fltk.lib(Fl_get_system_colors.obj) : error LNK2001: unresolved external symbol __imp__stricmp
OLDNAMES.lib(stricmp.obi) : error LNK2001: unresolved external symbol __imp__stricmp
fltk.lib(Fl_get_system_colors.obj) : error LNK2001: unresolved external symbol __imp__getenv
fltkgl.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__getenv
fltk.lib(fl_shortcut.obj) : error LNK2001: unresolved external symbol __imp__strtol
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__fread
fltk.lib(Fl_Text_Buffer.obj) : error LNK2001: unresolved external symbol __imp__fopen
fltk.lib(fl_draw.obj) : error LNK2001: unresolved external symbol __imp__strrchr
fltk.lib(Fl_Valuator.obj) : error LNK2001: unresolved external symbol __imp__floor
fltk.lib(fl_vertex.obj) : error LNK2001: unresolved external symbol __imp__floor
OLDNAMES.lib(putenv.obi) : error LNK2001: unresolved external symbol __imp___putenv
OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp___strdup
OLDNAMES.lib(stricmp.obi) : error LNK2001: unresolved external symbol __imp___stricmp
Release/code71.exe : fatal error LNK1120: 23 unresolved externals
Error executing link.exe.
Most of them involve fltk which reassure the fact that my setting of having libc.lib ignored was because of fltk....
I am lost here: no idea what to do to be able to use fltk AND to be able to use cout <<
ANY HELP would be GREATLY appreciated!!!
Before you freak out, let me explain what is happening...
You have several choices as to which CRT ("standard C Run-Time library") to use. The standard C Run-Time library contains most of the C library functions (such as malloc, free, printf, sprintf, ...). Generally, the choice of library is a combination of the choices of debug or release, static library or DLL, and single-threaded or multi-threaded.
Now, when you compile a library or an executable, you specify which CRT you are going to use. If you specify a CRT when you compile your executable that is different from the CRT that is specified for the FLTK library, you run into the problems that you are seeing.
The cleanest way to fix the problem is to figure out which CRT is used by FLTK and use the same one for your executable.
You have several choices as to which CRT ("standard C Run-Time library") to use. The standard C Run-Time library contains most of the C library functions (such as malloc, free, printf, sprintf, ...). Generally, the choice of library is a combination of the choices of debug or release, static library or DLL, and single-threaded or multi-threaded.
Now, when you compile a library or an executable, you specify which CRT you are going to use. If you specify a CRT when you compile your executable that is different from the CRT that is specified for the FLTK library, you run into the problems that you are seeing.
The cleanest way to fix the problem is to figure out which CRT is used by FLTK and use the same one for your executable.
I'm sorry but I give up! This library is just too stupid. I can get it to work under VS7, but not 6. I keep on getting an unresolved reference to __ftol2. I did lots of Googling, but I still can't get it. Take note that you must also link in:
wsock32.lib
ws2_32.lib
comctl32.lib
The library does use a multi-threaded runtime. I got that to work fine with iostream in 7. However, why do you want to use iostream? This library makes windows looking like apps, I do not know if you can do console at the same time. I'm sorry I can't help more, but I can't get anything to work and to me, if a library is this hard to get it to work, then I won;t use it. [smile] Good luck!
wsock32.lib
ws2_32.lib
comctl32.lib
The library does use a multi-threaded runtime. I got that to work fine with iostream in 7. However, why do you want to use iostream? This library makes windows looking like apps, I do not know if you can do console at the same time. I'm sorry I can't help more, but I can't get anything to work and to me, if a library is this hard to get it to work, then I won;t use it. [smile] Good luck!
Quote:
Original post by Drew_Benton
However, why do you want to use iostream? This library makes windows looking like apps, I do not know if you can do console at the same time.
IOStreams deal with more than the console. Case in point: std::fstream and std::stringstream.
franz1999 - did you build the FLTK lib from source?
Quote:
Original post by Fruny Quote:
Original post by Drew_Benton
However, why do you want to use iostream? This library makes windows looking like apps, I do not know if you can do console at the same time.
IOStreams deal with more than the console. Case in point: std::fstream and std::stringstream.
franz1999 - did you build the FLTK lib from source?
Bah! That was my thinking in why I had said that [lol]. I was thinking about fstream and the other stream stuff, but I forgot iostream referes to more than console. Talk about bad naming conventions :/. But then again, you use
I tried to build that FLTK as well from scratch, but I could not get it to work! I followed the instructions on the site, but I kept on getting linker erros that should not have popped up. I have since deleted that toolkit, so I can't report what they were. Maybe I am just not 'lucky' with this library... I did spend over 30mins with it last night though, and googled!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement