SA-MP Forums Archive
Best linux compiler - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: Best linux compiler (/showthread.php?tid=58405)



Best linux compiler - D4rkBlade - 17.12.2008

Hello,

I am developing some plugins for a server, but last week they installed linux in the server's datacenter. I'm not experienced with linux and unix systems. What linux compiler should I use to compile Visual C++ files without problems?


Re: Best linux compiler - D4rkBlade - 17.12.2008

Yeah, I know all that, I have adapted my whole code to work on linux and windows.
I am asking here because I saw some plugins like IRC that compiles in the both platforms.
Another question: Can I compile .so's on Windows using makefiles?


Re: Best linux compiler - Kowalski - 17.12.2008

I'm using G++. I write the codes with gedit and after complie it with the 'g++' command.

Ковалски


Re: Best linux compiler - D4rkBlade - 17.12.2008

I will use G++ too, it has windows and linux editions.
Thanks for the tip


Re: Best linux compiler - Kowalski - 25.12.2008

I had no idea where to post this problem, so I post it here. I want to make a plugin under Linux, but I have problems with the SA:MP Plugin SDK. I didn't touch the files, just unpack them in a folder. I built the files (helloworld.cpp and amxplugin.cpp) and I got 9 warnings. But not that's my problem. When I try to link the files, the linker gives an error: undefined reference to `main'. I have no idea how to use the helloworld.def file (under Linux). Someone knows the answer?

The commands I used:

g++ -DLINUX -Iamx/ -c helloworld.cpp ../SDK/amxplugin.cpp
g++ -DLINUX -Iamx/ -o HelloWorld helloworld.o amxplugin.o


I almost forgot, I'm using G++ complier.

Ковалски


Re: Best linux compiler - Kowalski - 25.12.2008

Doesn't work. Gives the same error with the 9 warnings. And how can I use the helloworld.def?

I quoted this from the SDK's readme.txt file:
Quote:

Linux also needs the compile flags "-DLINUX -Iamx/" with your favorite compiler

Ковалски


Re: Best linux compiler - mabako - 25.12.2008

Quote:

And how can I use the helloworld.def?

You don't need that on linux

and maybe your code would help us more... can't see any issues with "main" at this very moment, except the sa:mp server calls the function Load.

Quote:

Also, the libraries are different, so it's highly unlikely, unless you've exactly followed POSIX specifications, that you code will work without modification on Linux. Porting code from one platform to another is not simple. However, in answer to your question, GCC.

I had only 2 small problems porting my mysql-plugin to linux, which included not to use #include <windows.h> and change the mysql-include to <mysql/mysql.h>[me=mabako]throws some std classes around[/me]


Re: Best linux compiler - Kowalski - 25.12.2008

Код:
kowalski@kowalski:~/Asztal/sa-mp-0.2-plugin-sdk/HelloWorld$ g++ -D LINUX -I amx/ -o HelloWorld helloworld.cpp ../SDK/amxplugin.cpp
In file included from helloworld.cpp:8:
../SDK/amx/amx.h:215: warning: ‘packed’ attribute ignored for field of type ‘char [20]’
../SDK/amx/amx.h:265: warning: ‘packed’ attribute ignored for field of type ‘char’
../SDK/amx/amx.h:266: warning: ‘packed’ attribute ignored for field of type ‘char’
helloworld.cpp: In function ‘bool Load(void**)’:
helloworld.cpp:39: warning: deprecated conversion from string constant to ‘char*’
helloworld.cpp: In function ‘void Unload()’:
helloworld.cpp:49: warning: deprecated conversion from string constant to ‘char*’
helloworld.cpp: In function ‘cell n_HelloWorld(AMX*, cell*)’:
helloworld.cpp:62: warning: deprecated conversion from string constant to ‘char*’
In file included from ../SDK/plugin.h:9,
        from ../SDK/amxplugin.cpp:33:
../SDK/amx/amx.h:215: warning: ‘packed’ attribute ignored for field of type ‘char [20]’
../SDK/amx/amx.h:265: warning: ‘packed’ attribute ignored for field of type ‘char’
../SDK/amx/amx.h:266: warning: ‘packed’ attribute ignored for field of type ‘char’
/usr/lib/gcc/x86_64-linux-gnu/4.3.2/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
I got these errors with running the G++ complier on the SDK. I tried to compile the getch.c file too, but nothing changed.

EDIT:

I fixed all warnings with changing the logprintf format's type from char * to const char *, and redefined PACKED to simly packed (#define PACKED packed). The error still remain...

EDIT:

I almost forgot, that I changed one line in the amx.h file at the top of the file. When I tried to compile the files, the compiler didn't find the sclinux.h. So I had to replace the #include <sclinux.h> with the #include "sclinux.h".




EDIT:

I was dumb sorry, I know now how to compile it right, forgot everything I said before. Here's a new problem:

Код:
kowalski@kowalski:~/Asztal/sa-mp-0.2-plugin-sdk/HelloWorld$ make
gcc -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/amx/*.c
g++ -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/*.cpp
g++ -c -O3 -w -DLINUX -I../SDK/amx/ *.cpp
g++ -O2 -fshort-wchar -shared -o "helloworld.so" *.o
/usr/bin/ld: amxplugin.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
amxplugin.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [all] Error 1
I compiled as the compiler said (replaced -shared with -fPIC), and now gives again the 'main reference error' I mentioned above.

Ковалски


Re: Best linux compiler - Kowalski - 26.12.2008

Quote:
Originally Posted by Y_Leѕѕ
Err, do what I said!
Quote:
Originally Posted by Ковалски
Doesn't work.
I replaced the words in the makefile and tried again. Nothing changed...
Doesn't matter, I have a 64bit Linux system?

I always get this error:

Код:
/usr/bin/ld: amxplugin.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
amxplugin.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Ковалски


Re: Best linux compiler - Kowalski - 26.12.2008

Compiling a C++ project with a Python compiler? I don't think it works, but I give a try. How can I download it?

Ковалски


Re: Best linux compiler - Kowalski - 26.12.2008

I have Linux Ubuntu 8.10 84bit version.

Ковалски


Re: Best linux compiler - Kowalski - 26.12.2008

So I have to replace my system with a 32bit one... great... any advice?

Ковалски


Re: Best linux compiler - Rozzie - 26.12.2008

Quote:
Originally Posted by iTails
Python++ should be able to Compile.
where to download that?


Re: Best linux compiler - Kowalski - 27.12.2008

Thank you Y_Less! I reinstalled my operation system. It's now a 32bit Ubuntu. Now works the plugin perfect!

_________________________________________________

Next Question: Is that possible to install the Visual C++ compiler on Linux (32bit)? The synaptic package manager didn't find it, so I turn here to advice.

Ковалски


Re: Best linux compiler - Streetplaya - 27.12.2008

No. Visual C++ is Microsoft. Linux and Microsoft dont like each other..


Re: Best linux compiler - Y_Less - 27.12.2008

Quote:
Originally Posted by iTails
Python is pretty much Visual.
Python is a language, not a development suite.


Re: Best linux compiler - Kowalski - 28.12.2008

Quote:
Originally Posted by [1337
MaVe ]
No. Visual C++ is Microsoft. Linux and Microsoft dont like each other..
That's true, Microsoft doesn't develop softwares for Linux. I need a compiler to create DLLs and EXEs. Maybe it is possible with WINE or with something else?

Ковалски


Re: Best linux compiler - Y_Less - 28.12.2008

You can't make EXEs and DLLs on Linux, it doesn't use them.