SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 17/12/2008, 02:36 PM   #1
D4rkBlade
Little Clucker
 
Join Date: Jan 2007
Posts: 11
Reputation: 1
Default Best linux compiler

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?
D4rkBlade is offline   Reply With Quote
Old 17/12/2008, 03:07 PM   #2
D4rkBlade
Little Clucker
 
Join Date: Jan 2007
Posts: 11
Reputation: 1
Default Re: Best linux compiler

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?
D4rkBlade is offline   Reply With Quote
Old 17/12/2008, 03:30 PM   #3
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

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

Ковалски
Kowalski is offline   Reply With Quote
Old 17/12/2008, 03:52 PM   #4
D4rkBlade
Little Clucker
 
Join Date: Jan 2007
Posts: 11
Reputation: 1
Default Re: Best linux compiler

I will use G++ too, it has windows and linux editions.
Thanks for the tip
D4rkBlade is offline   Reply With Quote
Old 25/12/2008, 05:58 PM   #5
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

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.

Ковалски
Kowalski is offline   Reply With Quote
Old 25/12/2008, 10:20 PM   #6
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

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
Ковалски
Kowalski is offline   Reply With Quote
Old 25/12/2008, 10:34 PM   #7
mabako
Big Clucker
 
Join Date: Apr 2006
Posts: 112
Reputation: 3
Default Re: Best linux compiler

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]
mabako is offline   Reply With Quote
Old 25/12/2008, 10:41 PM   #8
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

Code:
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:

Code:
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.

Ковалски
Kowalski is offline   Reply With Quote
Old 26/12/2008, 12:11 PM   #9
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

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:

Code:
/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
Ковалски
Kowalski is offline   Reply With Quote
Old 26/12/2008, 12:43 PM   #10
Kowalski
Big Clucker
 
Join Date: Mar 2007
Posts: 68
Reputation: 1
Default Re: Best linux compiler

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

Ковалски
Kowalski is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Pawno Compiler] Unable to Execute the Compiler Fabio11 Client Support 6 26/09/2010 10:37 PM
samp linux server 03r5 doesn't run on 64 bits linux edelcat Server Support 2 08/09/2010 10:22 AM
Linux Pawn IDE & Compiler? Streetplaya General 13 27/05/2010 12:15 AM
PAWN 3.2.664 Compiler for Linux (CentOS 5) ev0lution Help Archive 0 20/10/2009 05:17 AM
pawn compiler for linux snoob Help Archive 0 27/08/2009 04:48 AM


All times are GMT. The time now is 05:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.