Problem_With_MSVC6_Linker
-
Hello, I have written a mathematical matrix class for VS C++ 6 and I would like to publish it in your site in the form of a library (*.lib). Maybe later I release the code too. However I am facing serious problems with my linker an I 'm not sure if I will ever manage to publish it (at least in a reasonable amount of time) without your help. So, I would like to ask you if you could help me a bit. I am willing to refer your name in my article. Although, it may take me some time to write it. As far as I have understood, it is the MFC (used by my class) that conflicts when I try to use my compiled *.lib file. I tried to change the settings of my linker (/NODEFAULTLIB) but I do not find the process familiar! I have uploaded the *.lib file and the header file so that you can test it on your own. It is at: http://rapidshare.com/files/41398859/LIB.zip[^] The process of compiling it into a LIB file seems to be OK. I will sum it up if you want: I added my header file and my cpp file into the project (Win32 Static Library) and I just built the lib files with no errors. Then I created a new MFC app (Dialog, MFC statically linked - I don't know if that matters), I added the header file and the lib files into the project, I added the #ifdef _DEBUG #pragma comment(lib, "mat_lib_DEBUG.lib") #else #pragma comment(lib, "mat_lib_RELEASE.lib") #endif in the code file using my class. But it just does't work. If you manage to compile a project while using an object please upload the project, so that I can see what I was doing wrong. If you wan't you may write sth here too. To use an object of the class write: CKelLib::CKelMatrix m,n(2,1); double p[4][4]={{1,2,3,4},{3,6,9.2,12.9},{7,14,21,27},{3,4,9,12.3}}; m.Initialize((double*)p,4,4); Any kind of help would be appreciated. Thank you.
kostas KEL
-
Hello, I have written a mathematical matrix class for VS C++ 6 and I would like to publish it in your site in the form of a library (*.lib). Maybe later I release the code too. However I am facing serious problems with my linker an I 'm not sure if I will ever manage to publish it (at least in a reasonable amount of time) without your help. So, I would like to ask you if you could help me a bit. I am willing to refer your name in my article. Although, it may take me some time to write it. As far as I have understood, it is the MFC (used by my class) that conflicts when I try to use my compiled *.lib file. I tried to change the settings of my linker (/NODEFAULTLIB) but I do not find the process familiar! I have uploaded the *.lib file and the header file so that you can test it on your own. It is at: http://rapidshare.com/files/41398859/LIB.zip[^] The process of compiling it into a LIB file seems to be OK. I will sum it up if you want: I added my header file and my cpp file into the project (Win32 Static Library) and I just built the lib files with no errors. Then I created a new MFC app (Dialog, MFC statically linked - I don't know if that matters), I added the header file and the lib files into the project, I added the #ifdef _DEBUG #pragma comment(lib, "mat_lib_DEBUG.lib") #else #pragma comment(lib, "mat_lib_RELEASE.lib") #endif in the code file using my class. But it just does't work. If you manage to compile a project while using an object please upload the project, so that I can see what I was doing wrong. If you wan't you may write sth here too. To use an object of the class write: CKelLib::CKelMatrix m,n(2,1); double p[4][4]={{1,2,3,4},{3,6,9.2,12.9},{7,14,21,27},{3,4,9,12.3}}; m.Initialize((double*)p,4,4); Any kind of help would be appreciated. Thank you.
kostas KEL
KEL3 wrote:
But it just does't work.
what makes you think it doesn't work?
image processing toolkits | batch image processing | blogging
-
KEL3 wrote:
But it just does't work.
what makes you think it doesn't work?
image processing toolkits | batch image processing | blogging
-
KEL3 wrote:
The dozens of linker errors I get.
And those would be?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
KEL3 wrote:
The dozens of linker errors I get.
And those would be?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
--------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:***
mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib
I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) -------------------------------- -
--------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:***
mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib
I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) -------------------------------- -
--------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:***
mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib
I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) -------------------------------- -
--------------------Configuration: mat_lib_test - Win32 Release-------------------- Normally I get: --------------------Configuration: mat_lib_test - Win32 Release-------------------- Linking... msvcrt.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: _time already defined in libcmt.lib(time.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __mbscmp already defined in libcmt.lib(mbscmp.obj) msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in libcmt.lib(mbctype.obj) LINK : warning LNK4098: defaultlib "mfc42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "mfcs42.lib" conflicts with use of other libs; use /NODEFAULTLIB:library LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library Release/mat_lib_test.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. mat_lib_test.exe - 6 error(s), 3 warning(s) --------------------------------------------------------------------------- After a few /nodefaultlib:***
mat_lib_RELEASE.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/mat_lib_test.pdb" /machine:I386 /nodefaultlib:"mfc42.lib" /nodefaultlib:"mfcs42.lib" /nodefaultlib:"msvcrt.lib" /out:"Release/mat_lib_test.exe" /defaultlib:mat_lib_RELEASE.lib
I get: Linking... LINK : warning LNK4049: locally defined symbol "_malloc" imported LINK : warning LNK4049: locally defined symbol "_free" imported LINK : warning LNK4049: locally defined symbol "_time" imported LINK : warning LNK4049: locally defined symbol "__mbscmp" imported mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __afxForceSTDAFX mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__srand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__rand mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__ceil mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__floor mat_lib_RELEASE.lib(CKelMatrix.obj) : error LNK2001: unresolved external symbol __imp__atof Release/mat_lib_test.exe : fatal error LNK1120: 6 unresolved externals Error executing link.exe. mat_lib_test.exe - 7 error(s), 4 warning(s) --------------------------------MFC applications cannot include ! Why don't you compile your matrix library with the same dependency as the MFC project that needs to use it? Anyway, the conflict occurs between libcmt.lib and msvcrt.lib, thus you can try removing one of them and keep the other... see which one (we can't 'cause don't have the source code). Regards,
Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.
-
MFC applications cannot include ! Why don't you compile your matrix library with the same dependency as the MFC project that needs to use it? Anyway, the conflict occurs between libcmt.lib and msvcrt.lib, thus you can try removing one of them and keep the other... see which one (we can't 'cause don't have the source code). Regards,
Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.
Ok! My problem was solved! All I had to do was to use MFC in a shared DLL in my application, as I did in my class. No linker directives at all! I guess that for apps using MFC in a static library you use MFC in a static library for your class... I 'll try this later. Thank you Borish. Thank you all, I 'll thank all of you, more, in my future article. BUT, Borish, what do you mean by "MFC applications cannot include !"? :doh: I include headers all the time in my MFC apps. Is there sth you can not include?
kostas KEL
-
Ok! My problem was solved! All I had to do was to use MFC in a shared DLL in my application, as I did in my class. No linker directives at all! I guess that for apps using MFC in a static library you use MFC in a static library for your class... I 'll try this later. Thank you Borish. Thank you all, I 'll thank all of you, more, in my future article. BUT, Borish, what do you mean by "MFC applications cannot include !"? :doh: I include headers all the time in my MFC apps. Is there sth you can not include?
kostas KEL
Sorry... that must be a typo, or a glitch when submitting a post (maybe interpreted as html code, 'cause I've used the xml kinda brackets)! :confused: I meant MFC applications cannot include windows.h... Very glad to hear that you solved your compilation issues. Congrats!
Bornish ESRI Developer Network Compilers demystified - Function pointers in Visual Basic 6.0 Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.