I write scripts in lua, but recently I started creating a module in C++. I only know the basics of this language.
I downloaded the example, created the project for Visual Studio with premake4. on Windows all works well, but Linux throws an error "Couldn't load module library!". I would be very thankful for explanation how to create a module for Linux.
Have you made sure it's _linux on the end of the .dll file's name and not _win32?
Of course
Linux binary != Windows binary.
You can't compile something on windows for linux without a crosscompilator.
[editline]22nd April 2016[/editline]
And don't even try to do that. Simply burn a linux image on an USB key, boot on it, and compile on it.
Can we see the code?
Thanks! I'll try to compile it in Linux
Code from Garry's example
I compiled linux-gmake using g++ and it created .so file. How I can create a .dll file?
You just rename the <name>_linux.so file to a <name>_linux.dll file. Don't ask it's because Garry. What .dll file is for Windows, the .so is for Linux.
I'm using premake4 created makefile, compiled it in linux, called gmsv_example_linux.dll. But it still runs with the same error.
In your server, run this and give us the output:
[code]ldd <your_module.so>[/code]
[QUOTE=Spoody;50198497][CODE]
sv_example.so
linux-vdso.so.1 (0x00007ffdc35c8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0d28a3b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0d2873a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0d28523000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0d28178000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0d28f4e000)
[/CODE][/QUOTE]
Ok, I'm not THAT familiar with Linux library setups in a mixed 32-bit and 64-bit environment, but I suspect that you compiled your module as 64-bit, which will never work with gmod. Make sure you compile it as 32-bit.
No, I'm compiled as 32-bit. I'm run premake with platform = x32
[QUOTE=Spoody;50202849]No, I'm compiled as 32-bit. I'm run premake with platform = x32[/QUOTE]
I just booted into Linux on my laptop, special for you. This is what a working module looks like:
[img]http://i.imgur.com/Cqo66Hg.png[/img]
I'm pretty sure you compiled it as 64-bit.
[QUOTE=guigui;50180148]Linux binary != Windows binary.
You can't compile something on windows for linux without a crosscompilator.
[editline]22nd April 2016[/editline]
[B]And don't even try to do that. Simply burn a linux image on an USB key, boot on it, and compile on it.[/B][/QUOTE]
Wrong, i did compile a lot of shit from WIN64 to ARM64 and i never had any problem;
It speedup the process.
Just install ubuntu with virtualbox so you can keep doing things at the same time.
I use a $5/month vps to host my teamspeak and compile things on it.
You can do the same.
I added swap to prevent segfaults while compiling and that's all.
Thank you all so much! I'm compiled it as 32-bit and it works.
I'm really sorry, but I ran into another strange problem. When I include the header icvar.h from SourceSDK 2013, it gives a huge pile of syntax errors. When I tried to include this header from SourceSDK 2007 I was given this
[CODE]
steam1@tommygodlike:~/fordll/gmod-module-base-master/example/linux-gmake$ make config=release32
==== Building gmsv_example (release32) ====
gm_example.cpp
In file included from /home/steam1/fordll/c++/public/tier1/interface.h:50:0,
from /home/steam1/fordll/c++/public/appframework/iappsystem.h:16,
from /home/steam1/fordll/c++/public/icvar.h:13,
from ../src/gm_example.cpp:6:
/home/steam1/fordll/c++/public/tier0/platform.h:46:17: fatal error: new.h: No such file or directory
#include <new.h>
^
compilation terminated.
gmsv_example.make:128: recipe for target 'obj/x32/gm_example.o' failed
make[1]: *** [obj/x32/gm_example.o] Error 1
Makefile:16: recipe for target 'gmsv_example' failed
make: *** [gmsv_example] Error 2
[/CODE]
Can you explain for a noob how to include the headers from the SourceSDK in Linux?
Maybe don't try to cheat?
But you are also not setting the correct paths for sourcesdk.
[QUOTE=MeepDarknessM;50241201]Maybe don't try to cheat[/QUOTE]
What do you mean?
On Windows all works well, this problem only on Linux. I do not think that this is due to paths, there is no new.h in the SourceSDK
Sorry, you need to Log In to post a reply to this thread.