Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - acrtused and linking with static libs
If I use a static library with main() inside the library, OPTLINK complains about "no start address", and also "no stack", in case of console programs. I used LIBUNRES, and the main module is in the lib, and even extern __acrtused_con. This also happens with WinMain() instead of a library (I had this problem with V GUI toolkit). For example: // main.cpp #include <iostream.h> extern const char *about(); int main() { cout << about() << endl; // BTW, I see a pointer here, instead of the text! return 0; } // about.cpp const char *about() { return "DM LIB test"; } Now, compile everything: sc -c -mn -WA about.cpp sc -c -mn -WA main.cpp lib main.lib /c /noi main.obj sc -omain.exe about.obj main.lib // this fails sc -omain.exe about.obj main.obj // okay Is there something that can be done about this? Is it a linker bug? Laurentiu Sep 15 2001
The problem is that there's no reference in about.obj to pull in main.obj from the library. The linker only pulls in modules from a .lib file that are referenced. Pull main.obj out of the .lib file and link it in explicitly. -Walter Laurentiu Pancescu wrote in message <9nvbg7$uhr$1 digitaldaemon.com>...If I use a static library with main() inside the library, OPTLINK complains about "no start address", and also "no stack", in case of console programs. I used LIBUNRES, and the main module is in the lib, and even extern __acrtused_con. This also happens with WinMain() instead of a library (I had this problem with V GUI toolkit). For example: // main.cpp #include <iostream.h> extern const char *about(); int main() { cout << about() << endl; // BTW, I see a pointer here, instead of the text! return 0; } // about.cpp const char *about() { return "DM LIB test"; } Now, compile everything: sc -c -mn -WA about.cpp sc -c -mn -WA main.cpp lib main.lib /c /noi main.obj sc -omain.exe about.obj main.lib // this fails sc -omain.exe about.obj main.obj // okay Is there something that can be done about this? Is it a linker bug? Laurentiu Sep 15 2001
"Walter" <walter digitalmars.com> wrote:The problem is that there's no reference in about.obj to pull in main.obj from the library. The linker only pulls in modules from a .lib file that are referenced. Pull main.obj out of the .lib file and link it in explicitly. -Walter Sep 16 2001
Laurentiu Pancescu wrote in message <9o1scb$29m9$1 digitaldaemon.com>..."Walter" <walter digitalmars.com> wrote:The problem is that there's no reference in about.obj to pull in main.obj from the library. The linker only pulls in modules from a .lib file that Sep 16 2001
|