Raised This Month: $7 Target: $400
 1% 

Solved GCC version 4.6.4 and C++11


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-26-2018 , 15:30   GCC version 4.6.4 and C++11
Reply With Quote #1

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?

Last edited by kadet.89; 10-28-2018 at 14:58.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-26-2018 , 17:51   Re: GCC version 4.6.4 and C++11
Reply With Quote #2

SM doesn't link/use libstdc++.
Fyren is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-26-2018 , 22:06   Re: GCC version 4.6.4 and C++11
Reply With Quote #3

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.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-28-2018 , 14:48   Re: GCC version 4.6.4 and C++11
Reply With Quote #4

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.

Last edited by kadet.89; 10-30-2018 at 05:55.
kadet.89 is offline
Send a message via Skype™ to kadet.89
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

Forum Jump


All times are GMT -4. The time now is 22:00.


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