Subj : Unresolved external __declspec(dllimport), and illegal instruction To : borland.public.cpp.borlandcpp From : MikL Date : Wed Nov 17 2004 10:35 pm Hi all, I've never used C/C++ to write a Windows app (only console apps), and I'm hitting an error that suggests I'm ignorantly misusing the Bcc32 compiler ("Borland C++ 5.5 for Win32" with "Turbo Incremental Link 5.00") under WinXP. In case it's relevant, I'm attempting to compile the Sun Java launcher (java.c + java_md.c). I've been getting many "unresolved references" where java_md.c calls functions in java.c, despite the presence of good-looking function prototypes. To try to track down the problem, I merged the source code from both files into a single source file and compiled that. All of the unresolved reference errors went away, with the exception of one referring to "___initenv", which appears as follows in the source: __declspec(dllimport) char **__initenv; int WINAPI WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow) { int ret; SetThreadLocale(GetSystemDefaultLCID()); __initenv = _environ; ret = main(__argc, __argv); return ret; } What do I need to do? I've been Googling, and seen a few references to IMPLIB and COFF2OMF, but I've done my head in trying to understand what they're used for and how to use them...and I don't know if they're related to my problem anyway :( I've never even built a DLL. The compile command I'm using is as follows. I've broken it into multiple lines here for readability: bcc32 -5 -tW -DJAVAW -DWIN32 "-IC:\Program Files\Borland\bcc55\Include" "-IC:\Program Files\Java\j2sdk1.4.2_03\include" "-IC:\Program Files\Java\j2sdk1.4.2_03\include\win32" "-LC:\Program Files\Borland\bcc55\Lib" -DJDK_MAJOR_VERSION=\"1\" -DJDK_MINOR_VERSION=\"4\" "-DJAVA_ARGS={ \"heysen.common.ui.UiDialog_Test\" }" "-DAPP_CLASSPATH={ \"testapp.jar\" }" -otestapp.exe java_all.c Sadly, if I remove the references to __initenv, I get an executable, but when I try to run it I get the following error (in a GUI dialog): [TITLE: 16 bit MS-DOS Subsystem] testapp.exe The NTVDM CPU has encountered an illegal instruction. CS:0e25 IP:010c OP:2e 63 00 88 13 Choose 'Close' to terminate the application. Thank you for your patience in reading this far! .