AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Solved GCC version 4.6.4 and C++11 (https://forums.alliedmods.net/showthread.php?t=311631)

kadet.89 10-26-2018 15:30

GCC version 4.6.4 and C++11
 
I ran into a problem trying to build an extension against GCC 4.6.4: libstdc++.so.6.0.16
CS:S servers come with GLIBCXX_3.4.16 library and the VDS, that I need to run the extension on can't be updated to a newer version.
The server starts and works just fine, but my extension doesn't work:
Quote:

[05] <FAILED> file "extension.ext.2.css.so": bin/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /server/cstrike/addons/sourcemod/extensions/extension.ext.2.css.so)
I tried to rebuild it against 4.6.4:

Quote:

d@ubuntu:~/SDK/sourcemod/build$ python ../configure.py --sdks css
Checking CC compiler (vendor test gcc)... ['cc', 'test.c', '-o', 'test']
not found
Checking CC compiler (vendor test gcc)... ['gcc', 'test.c', '-o', 'test']
found gcc version 4.6
Checking CXX compiler (vendor test gcc)... ['c++', 'test.cpp', '-o', 'testp']
not found
Checking CXX compiler (vendor test gcc)... ['g++', 'test.cpp', '-o', 'testp']
found gcc version 4.6
And got this error:
Quote:

cc1plus: error: unrecognized command line option ‘-std=c++11’
Then I changed the std to '-std=c++0x'
And now I get this error:

Quote:

/home/d/SDK/sourcemod/public/IPluginSys.h:286:47: error: expected ‘;’ at end of member declaration
/home/d/SDK/sourcemod/public/IPluginSys.h:286:49: error: ‘final’ does not name a type
I'm a bit confused here. Sourcemod and all default extensions run just fine, and I see C++11, which can't work with gcc 4.6.4 (can it?).
The question is what is the right ambuild configuration to build extensions against 4.6.4?

In the documentation it's said that GCC 4.7+ is required for sm 1.7+. I've got sm 1.9 and GCC 4.6.1 on the VDS. Does sm has own built-in GCC library?

Fyren 10-26-2018 17:51

Re: GCC version 4.6.4 and C++11
 
SM doesn't link/use libstdc++.

nosoop 10-26-2018 22:06

Re: GCC version 4.6.4 and C++11
 
SourceMod uses the AMTL in place of the C++ standard libraries.

You'll either want to spin up a VM with the appropriate / older libstdc++, rewrite portions of your extension against the AMTL, or add -static-libstdc++ to your linker flags in your AMBuildScript at around this line.

kadet.89 10-28-2018 14:48

Re: GCC version 4.6.4 and C++11
 
Thanks for your help, now I see how it works.
I checked the extensions this way:
Quote:

> nm /home/d/SDK/sourcemod/build/extensions/Extension/Extension/extension.ext.2.css/extension.ext.2.css.so
And found out that there are std::string and unordered_* container symbols from 18-21 versions.
I made these changes:
Quote:

std::unordered_set -> std::tr1::unordered_set
std::unordered_map -> std::tr1::unordered_map
std::unordered_multimap -> std::tr1::unordered_multimap
cxx.cxxflags += '-D_GLIBCXX_USE_CXX11_ABI=0'
And it pushed the required version from 21-18 to 14.

Here are some symbols from 18+ versions, that I had to get rid of:
Quote:

_ZSt24__throw_out_of_range_fmtPKcz@@GLIBCXX_3 .4.20 // std::vector::at()
_ZNKSt7__cxx1112basic_stringIcSt11char_traits IcESaIcEE5c_strEv@@GLIBCXX_3.4.21 // std::string
_ZNKSt8__detail20_Prime_rehash_policy14_M_nee d_rehashEjjj@@GLIBCXX_3.4.18 // unordered containers
It wasn't clear at first where these symbols came from, as there were no direct use of "throw_out_of_range" or "Prime_rehash_policy" in my code. The idea is to open the compiled extension in IDA and check the symboils in it via "text search". Then it gets clear in which subroutione and where exactelly the symbols are used. F5 shows pseudocode, which helps to analyze how the source code comes to these symbols.


All times are GMT -4. The time now is 11:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.