Sign in to follow this  

control which symbols are exported in gcc

This topic is 3591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am writing a game engine for linux in c. I want to be able to load all games as shared objects instead of statically linking them into the game engine. However, the only way i can figure out to export functions from the engine to the games is by using the -export-dynamic option, which I don't think is a good idea because it exports every symbol, and I only need to export some of them. Can anyone please help me find a way to control which symbols are exported and which aren't on gcc?

Share this post


Link to post
Share on other sites
What's wrong with exporting every symbol? C has no namespaces, but it's commonplace to add an prefix_ to all function and type names. If you do that, you should have no problems exporting all symbols.

This seems backwards though. Why compile the engine as the executable and the game as the library? It's usually done the other way around.

Share this post


Link to post
Share on other sites
Quote:
Original post by jonahrowley
What's wrong with exporting every symbol?


1. It slows down startup time.
2. Calling exported functions is slower (even if you're calling within the same library).
3. The compiler can't optimize calls to exported functions.
4. Namespace pollution.

Share this post


Link to post
Share on other sites
Sign in to follow this