- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code uses just one module to declare a few variable. I try to
compile this module separately, and the linker spits out a *.mod file
but gives the error:
libifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol MAIN__
referenced in function main
cmb_com.exe : fatal error LNK1120: 1 unresolved externals
I don't know what this comes from, but I can go ahead and compile my main program with the module. It compiles fine, but when it goes to the linker, the linker gives an error for each of the variables declared in the module, such as:
myNec4d11_rev2.obj : error LNK2019: unresolved external symbol CMB_COM_mp_IP ref
erenced in function MAIN__
myNec4d11_rev2.obj : error LNK2019: unresolved external symbol CMB_COM_mp_NEQMAT
referenced in function MAIN__
It should be able to find the module, so I don't understand what's going on. BTW, this only happens when I try to use the 64bit compiler from the command line. I can compile and link the whole thing from VS for the 32bit compiler. Any guidance as to what I'm doing wrong would be appreciated.
thanks,
Dillon
libifcoremd.lib(for_main.obj) : error LNK2019: unresolved external symbol MAIN__
referenced in function main
cmb_com.exe : fatal error LNK1120: 1 unresolved externals
I don't know what this comes from, but I can go ahead and compile my main program with the module. It compiles fine, but when it goes to the linker, the linker gives an error for each of the variables declared in the module, such as:
myNec4d11_rev2.obj : error LNK2019: unresolved external symbol CMB_COM_mp_IP ref
erenced in function MAIN__
myNec4d11_rev2.obj : error LNK2019: unresolved external symbol CMB_COM_mp_NEQMAT
referenced in function MAIN__
It should be able to find the module, so I don't understand what's going on. BTW, this only happens when I try to use the 64bit compiler from the command line. I can compile and link the whole thing from VS for the 32bit compiler. Any guidance as to what I'm doing wrong would be appreciated.
thanks,
Dillon
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dillon,
When you compile a file with a module the compiler spits out two (or more) files:
modname.MOD
filename.OBJ
Think of the modname.MOD file as a pre-compiled header who's modname is the name affixed after the keyword module within the source file, and the filename.OBJ object file of the source file provided that the module instantiates some data or code.
When you compile other files the USE modename will cause the compiler to look for the "pre-compiled header" modname.MOD.
When you link the application, and if the module instantiates data or code, then you must also link in the filename.OBJ for the module.
Generally the programmer will name the file name the same as the module name but there is no requirement to do so.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cool, thanks a lot for the reply. I had thought that putting the .mod and .obj in the library or include path would have been enough. It seems I have to directly include them in the call to the compiler/linker. I wish there was a full paper manual for this thing; the documentation just isn't enough for me.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page