• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

[TUTORIAL] Compiling the DLL on Linux

I took the time to setup everything with the GNUmakefile solution. Unfortunately I get an error in the # Link objects. step of the makefile:

LINK : fatal error LNK1104: cannot open file 'Project/CvGameCoreDLL.def'
LINK : fatal error LNK1141: failure during build of exports file
make: *** [GNUmakefile:104: release/CvGameCoreDLL.dll] Error 117

My question what is this CvGameCoreDLL.def? I didn't find any file of that kind in my setup?

Thanks a lot for the great explanations so far.
Thank you for testing it.

The def file is an oversight; I inherited it from AdvCiv, but it shouldn't be in the default makefile. (Instead, you'd just set LDFLAGS in .settings if your mod needs it. Probably I should document this too...)
I've updated the makefile (and the link to the zip). Could you please try it again?
 
Tried it with the following result, but right now I don't have much time to analyse.

Creating library release/CvGameCoreDLL.lib and object release/CvGameCoreDLL.exp
CvGame.obj : error LNK2019: unresolved external symbol "int __cdecl boost::xtime_get(struct boost::xtime *,int)" (?xtime_get@boost@@YAHPAUxtime@1@H@Z) referenced in function "private: void __thiscall Timer::c
alc_next_time(void)" (?calc_next_time@Timer@@AAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::detail::condition_impl::condition_impl(void)" (??0condition_impl@detail@boost@@QAE@XZ) referenced in function "public: __thisc
all boost::condition::condition(void)" (??0condition@boost@@QAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::detail::condition_impl::~condition_impl(void)" (??1condition_impl@detail@boost@@QAE@XZ) referenced in function "public: __this
call boost::condition::~condition(void)" (??1condition@boost@@QAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::detail::condition_impl::notify_one(void)" (?notify_one@condition_impl@detail@boost@@QAEXXZ) referenced in function "publi
c: void __thiscall boost::condition::notify_one(void)" (?notify_one@condition@boost@@QAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_lock(void)" (?do_lock@mutex@boost@@AAEXXZ) referenced in function "public: static void __cdecl boost::detail::
thread::lock_ops<class boost::mutex>::lock(class boost::mutex &)" (?lock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_unlock(void)" (?do_unlock@mutex@boost@@AAEXXZ) referenced in function "public: static void __cdecl boost::deta
il::thread::lock_ops<class boost::mutex>::unlock(class boost::mutex &)" (?unlock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_lock(void * &)" (?do_lock@mutex@boost@@AAEXAAPAX@Z) referenced in function "public: static void __cdecl boost:
:detail::thread::lock_ops<class boost::mutex>::lock(class boost::mutex &,void * &)" (?lock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@AAPAX@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_unlock(void * &)" (?do_unlock@mutex@boost@@AAEXAAPAX@Z) referenced in function "public: static void __cdecl bo
ost::detail::thread::lock_ops<class boost::mutex>::unlock(class boost::mutex &,void * &)" (?unlock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@AAPAX@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::mutex::~mutex(void)" (??1mutex@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Timer@@QAE@X
Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Timer@@QA
E@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join@thread@boost@@QAEXXZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Time
r@@QAE@XZ)
CvGame.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::lock_error::~lock_error(void)" (??1lock_error@boost@@UAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::lock_error::lock_error(void)" (??0lock_error@boost@@QAE@XZ) referenced in function "public: void __thiscall boost::detail::thr
ead::scoped_lock<class boost::mutex>::lock(void)" (?lock@?$scoped_lock@Vmutex@boost@@@thread@detail@boost@@QAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall boost::thread_exception::~thread_exception(void)" (??1thread_exception@boost@@UAE@XZ) referenced in function "public: virtual
void * __thiscall boost::thread_exception::`scalar deleting destructor'(unsigned int)" (??_Gthread_exception@boost@@UAEPAXI@Z)
CvGame.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall boost::lock_error::what(void)const " (?what@lock_error@boost@@UBEPBDXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: bool __thiscall boost::detail::condition_impl::do_timed_wait(struct boost::xtime const &)" (?do_timed_wait@condition_impl@detail@boost@@QAE_NABU
xtime@3@@Z) referenced in function "private: bool __thiscall boost::condition::do_timed_wait<class boost::mutex>(class boost::mutex &,struct boost::xtime const &)" (??$do_timed_wait@Vmutex@boost@@@condition@b
oost@@AAE_NAAVmutex@1@ABUxtime@1@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::detail::condition_impl::enter_wait(void)" (?enter_wait@condition_impl@detail@boost@@QAEXXZ) referenced in function "priva
te: bool __thiscall boost::condition::do_timed_wait<class boost::mutex>(class boost::mutex &,struct boost::xtime const &)" (??$do_timed_wait@Vmutex@boost@@@condition@boost@@AAE_NAAVmutex@1@ABUxtime@1@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::thread(class boost::function0<void,class std::allocator<class boost::function_base> > const &)" (??0thread@boost@@QAE@
ABV?$function0@XV?$allocator@Vfunction_base@boost@@@std@@@1@@Z) referenced in function "public: __thiscall Timer::Timer(struct boost::xtime const &,class CvGame *)" (??0Timer@@QAE@ABUxtime@boost@@PAVCvGame@@@
Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::mutex::mutex(void)" (??0mutex@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::Timer(struct boost::xtime const
&,class CvGame *)" (??0Timer@@QAE@ABUxtime@boost@@PAVCvGame@@@Z)
release/CvGameCoreDLL.dll : fatal error LNK1120: 19 unresolved externals
make: *** [GNUmakefile:104: release/CvGameCoreDLL.dll] Error 96
 
Tried it with the following result, but right now I don't have much time to analyse.

Creating library release/CvGameCoreDLL.lib and object release/CvGameCoreDLL.exp
CvGame.obj : error LNK2019: unresolved external symbol "int __cdecl boost::xtime_get(struct boost::xtime *,int)" (?xtime_get@boost@@YAHPAUxtime@1@H@Z) referenced in function "private: void __thiscall Timer::c
alc_next_time(void)" (?calc_next_time@Timer@@AAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::detail::condition_impl::condition_impl(void)" (??0condition_impl@detail@boost@@QAE@XZ) referenced in function "public: __thisc
all boost::condition::condition(void)" (??0condition@boost@@QAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::detail::condition_impl::~condition_impl(void)" (??1condition_impl@detail@boost@@QAE@XZ) referenced in function "public: __this
call boost::condition::~condition(void)" (??1condition@boost@@QAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::detail::condition_impl::notify_one(void)" (?notify_one@condition_impl@detail@boost@@QAEXXZ) referenced in function "publi
c: void __thiscall boost::condition::notify_one(void)" (?notify_one@condition@boost@@QAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_lock(void)" (?do_lock@mutex@boost@@AAEXXZ) referenced in function "public: static void __cdecl boost::detail::
thread::lock_ops<class boost::mutex>::lock(class boost::mutex &)" (?lock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_unlock(void)" (?do_unlock@mutex@boost@@AAEXXZ) referenced in function "public: static void __cdecl boost::deta
il::thread::lock_ops<class boost::mutex>::unlock(class boost::mutex &)" (?unlock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_lock(void * &)" (?do_lock@mutex@boost@@AAEXAAPAX@Z) referenced in function "public: static void __cdecl boost:
:detail::thread::lock_ops<class boost::mutex>::lock(class boost::mutex &,void * &)" (?lock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@AAPAX@Z)
CvGame.obj : error LNK2019: unresolved external symbol "private: void __thiscall boost::mutex::do_unlock(void * &)" (?do_unlock@mutex@boost@@AAEXAAPAX@Z) referenced in function "public: static void __cdecl bo
ost::detail::thread::lock_ops<class boost::mutex>::unlock(class boost::mutex &,void * &)" (?unlock@?$lock_ops@Vmutex@boost@@@thread@detail@boost@@SAXAAVmutex@4@AAPAX@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::mutex::~mutex(void)" (??1mutex@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Timer@@QAE@X
Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Timer@@QA
E@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::thread::join(void)" (?join@thread@boost@@QAEXXZ) referenced in function "public: __thiscall Timer::~Timer(void)" (??1Time
r@@QAE@XZ)
CvGame.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::lock_error::~lock_error(void)" (??1lock_error@boost@@UAE@XZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::lock_error::lock_error(void)" (??0lock_error@boost@@QAE@XZ) referenced in function "public: void __thiscall boost::detail::thr
ead::scoped_lock<class boost::mutex>::lock(void)" (?lock@?$scoped_lock@Vmutex@boost@@@thread@detail@boost@@QAEXXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall boost::thread_exception::~thread_exception(void)" (??1thread_exception@boost@@UAE@XZ) referenced in function "public: virtual
void * __thiscall boost::thread_exception::`scalar deleting destructor'(unsigned int)" (??_Gthread_exception@boost@@UAEPAXI@Z)
CvGame.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall boost::lock_error::what(void)const " (?what@lock_error@boost@@UBEPBDXZ)
CvGame.obj : error LNK2019: unresolved external symbol "public: bool __thiscall boost::detail::condition_impl::do_timed_wait(struct boost::xtime const &)" (?do_timed_wait@condition_impl@detail@boost@@QAE_NABU
xtime@3@@Z) referenced in function "private: bool __thiscall boost::condition::do_timed_wait<class boost::mutex>(class boost::mutex &,struct boost::xtime const &)" (??$do_timed_wait@Vmutex@boost@@@condition@b
oost@@AAE_NAAVmutex@1@ABUxtime@1@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::detail::condition_impl::enter_wait(void)" (?enter_wait@condition_impl@detail@boost@@QAEXXZ) referenced in function "priva
te: bool __thiscall boost::condition::do_timed_wait<class boost::mutex>(class boost::mutex &,struct boost::xtime const &)" (??$do_timed_wait@Vmutex@boost@@@condition@boost@@AAE_NAAVmutex@1@ABUxtime@1@@Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::thread(class boost::function0<void,class std::allocator<class boost::function_base> > const &)" (??0thread@boost@@QAE@
ABV?$function0@XV?$allocator@Vfunction_base@boost@@@std@@@1@@Z) referenced in function "public: __thiscall Timer::Timer(struct boost::xtime const &,class CvGame *)" (??0Timer@@QAE@ABUxtime@boost@@PAVCvGame@@@
Z)
CvGame.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::mutex::mutex(void)" (??0mutex@boost@@QAE@XZ) referenced in function "public: __thiscall Timer::Timer(struct boost::xtime const
&,class CvGame *)" (??0Timer@@QAE@ABUxtime@boost@@PAVCvGame@@@Z)
release/CvGameCoreDLL.dll : fatal error LNK1120: 19 unresolved externals
make: *** [GNUmakefile:104: release/CvGameCoreDLL.dll] Error 96
Forget my last post. It has nothing to do with your changes. What I forgot to mention is that I already have my mod, which I previously developed on windows. This mod is partially based on Ramkhamhaeng's PBmod. The errors above are caused by some code from PBmod. After I removed those code sections the DLL compiled without an issue and the game is working with it.

Thanks a lot for the setup.
 
I inherited it from AdvCiv
I was wondering about that. AdvCiv is the only mod, which I know for a fact is using a def file. That's why I got a bit puzzled with that error and asked which mod was being compiled.

After I removed those code sections the DLL compiled without an issue and the game is working with it.
Congratulations [party]
It's such a nice feeling when you finally get a compiler to work after struggling with it for a while. Sure the real work starts now that you can develop your mod, but at least now each change is progress towards something better rather than "just getting it to work". That also makes the work a whole lot more fun.
 
Unfortunately I haven't been able to replicate my earlier success, because whenever I try compiling:

Code:
Wine cannot find the ncurses library (libncurses.so.5).

I've tried several different ways of acquiring said library, and should have it installed, and yet Wine cannot find it. What's going on? Am I supposed to install it in a wine prefix? Is it a 32 vs 64 bit thing? It's really frustrating bashing my head against this wall. I even did away with all my previous work and started over from scratch, retracing every step in this guide from the very beginning, only to run into this same error again. A little help please? :blush:
 
Hmm... are you using wine 1.7? If so, try the system wine instead (that you got from the package manager.)

PS. also feel free to beta test try the guide v2, it may work better...
I've actually spent some time trying to get back into modding lately, and made a greatly updated version of this guide [...]
 
Hmm... are you using wine 1.7? If so, try the system wine instead (that you got from the package manager.)

PS. also feel free to beta test try the guide v2, it may work better...
Good news: Trying out the newer version of your guide took care of my initial problem.

Bad news: Now when trying to compile I get

Code:
z:\home\imperator-knoedel\Desktop\stuff\Civ4Modding\Misc\DLLstuff\Linuxified Leo
rethSourceCode\CvGameCoreDLL\CvGameCoreDLL.h(17) : fatal error C1083: Cannot ope
n include file: 'windows.h': No such file or directory

Thanks for the assistance so far at any rate!
 
It looks like a platform SDK problem, but I'm clueless as to why it's happening.
As a "turn it off and on again" kind of attempt: nuke the 'Windows SDK' directory and then
Tried this to no avail.

However, I can't help but notice that this "Microsoft Platform SDK" keeps installing into "Program Files" and not "Program Files (x86)", which triggers my 32 vs 64 bit sense. Is that relevant? Also, "nuking" it is kind of harder than it sounds. When I try using the setup.exe to destroy the setup.exe the installer crashes sometime during deinstallation. Manual deletion doesn't seem to be registered by the installer either, it gives me the options "Add/Remove", "Remove All", and "Reinstall", which doesn't sound to me like a fresh install, but treating a corpse as if it were still alive if you get me.
 
However, I can't help but notice that this "Microsoft Platform SDK" keeps installing into "Program Files" and not "Program Files (x86)", which triggers my 32 vs 64 bit sense. Is that relevant
Good observation... if you look at the .settings file, you'll see it says Program Files (x86). Try moving the platform SDK there and see what happens.
(I guess such a mismatch may happen if your wineprefix is 32-bit. Maybe the makefile should try to account for this somehow, or at least the guide should be changed to warn about this.)
 
Good observation... if you look at the .settings file, you'll see it says Program Files (x86). Try moving the platform SDK there and see what happens.
(I guess such a mismatch may happen if your wineprefix is 32-bit. Maybe the makefile should try to account for this somehow, or at least the guide should be changed to warn about this.)
No change. I am using a 64-bit wineprefix, but I figured since we are deep in early 2000s programming here maybe something somewhere thinks it's in a 32-bit system when it's not.

The PSDK image has three setup files, one called "setup64" and another "setupa64" in addition to the one I've been using so far. The former just won't launch at all, but the second does install the Microsoft Platform SDK into the regular Program Files. However editing .settings to point at that one appears to have no effect.

Code:
make
mkdir -p release
wine "C:/Program Files (x86)/Civ4SDK/Microsoft Visual C++ Toolkit 2003"/bin/cl.exe _precompile.cpp /MD /nologo /GR /Gy /W3 /EHsc /Gd /Gm- /DWIN32 /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /YuCvGameCoreDLL.h /c /Fprelease/CvGameCoreDLL.pch /I"C:/Program Files (x86)/Civ4SDK/Microsoft Visual C++ Toolkit 2003"/include /I"C:/Program Files/Microsoft Platform SDK"/Include /I"C:/Program Files/Microsoft Platform SDK"/Include/mfc /I./Boost-1.32.0/include /I./Python24/include /O2 /Oy /Oi /G7 /DNDEBUG /DFINAL_RELEASE /YcCvGameCoreDLL.h /Forelease/_precompile.obj
_precompile.cpp
z:\home\imperator-knoedel\Desktop\stuff\Civ4Modding\Misc\DLLstuff\Linuxified Leo
rethSourceCode\CvGameCoreDLL\CvGameCoreDLL.h(17) : fatal error C1083: Cannot ope
n include file: 'windows.h': No such file or directory
Segmentation fault (core dumped)

This is what my .settings file looks like right now in case it's relevant:

Code:
# Wine errors are annoying; ignore them.
WINE = wine 2>/dev/null
# Available targets: debug, release, final_release.
# Note the capitalization! Only lower-case is recognized.
TARGET = release
# Path to the wine executable
WINE = wine
# Path to the fastdep executable
FASTDEP = bin/fastdep-0.16/fastdep
# Path to the directory containing the Microsoft Platform SDK
# Original: PSDK = "C:/Program Files (x86)/Microsoft Platform SDK"
PSDK = "C:/Program Files/Microsoft Platform SDK"
# Path to the directory containing the Visual C++ Toolkit
VCTOOLKIT = "C:/Program Files (x86)/Civ4SDK/Microsoft Visual C++ Toolkit 2003"
# Path to the directory containing the Python 2.4 sources
PYTHON = ./Python24
# Path to the directory containing the Boost 1.32.0 sources
BOOST = ./Boost-1.32.0
# Directory to output CvGameCoreDLL.dll in.
# Original: OUTDIR = ../Assets
OUTDIR = ../Prototype/CvGameCoreDLL.dll

Edit: Changed the last line in .settings to point at a folder rather than a file. It had no effect on my current situation but I figured better save than sorry.
 
Back
Top Bottom