diff --git a/build/premake/premake.lua b/build/premake/premake.lua index abc873d51c..3bb523b5e0 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -109,6 +109,14 @@ function package_set_build_flags() "-ffast-math", }) end + + tinsert(package.buildoptions, { + -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with + -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default"))) + "-fvisibility=hidden", + "-fvisibility-inlines-hidden", + }) + package.includepaths = { "/usr/X11R6/include/X11", "/usr/include/X11", diff --git a/source/collada/DLL.cpp b/source/collada/DLL.cpp index 4dad5de2cd..62ca470daa 100644 --- a/source/collada/DLL.cpp +++ b/source/collada/DLL.cpp @@ -14,7 +14,7 @@ void default_logger(int severity, const char* message) static LogFn g_Logger = &default_logger; -void set_logger(LogFn logger) +EXPORT void set_logger(LogFn logger) { if (logger) g_Logger = logger; @@ -108,12 +108,12 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi return 0; } -int convert_dae_to_pmd(const char* dae, OutputFn pmd_writer, void* cb_data) +EXPORT int convert_dae_to_pmd(const char* dae, OutputFn pmd_writer, void* cb_data) { return convert_dae_to_whatever(dae, pmd_writer, cb_data, ColladaToPMD); } -int convert_dae_to_psa(const char* dae, OutputFn psa_writer, void* cb_data) +EXPORT int convert_dae_to_psa(const char* dae, OutputFn psa_writer, void* cb_data) { return convert_dae_to_whatever(dae, psa_writer, cb_data, ColladaToPSA); } diff --git a/source/collada/DLL.h b/source/collada/DLL.h index d654d1a71a..91d8e533fe 100644 --- a/source/collada/DLL.h +++ b/source/collada/DLL.h @@ -8,12 +8,16 @@ extern "C" #ifdef _WIN32 # ifdef COLLADA_DLL -# define EXPORT extern __declspec(dllexport) +# define EXPORT extern "C" __declspec(dllexport) # else -# define EXPORT extern __declspec(dllimport) +# define EXPORT extern "C" __declspec(dllimport) # endif #else -# define EXPORT extern +# if __GNUC__ >= 4 +# define EXPORT extern "C" __attribute__ ((visibility ("default"))) +# else +# define EXPORT extern "C" +# endif #endif #define LOG_INFO 0 diff --git a/source/collada/GeomReindex.cpp b/source/collada/GeomReindex.cpp index 270ce593b8..9ef21de65c 100644 --- a/source/collada/GeomReindex.cpp +++ b/source/collada/GeomReindex.cpp @@ -78,7 +78,7 @@ struct InserterWithoutDuplicates size_t add(const T& val) { - std::map::iterator it = btree.find(val); + typename std::map::iterator it = btree.find(val); if (it != btree.end()) return it->second; diff --git a/source/collada/PMDConvert.cpp b/source/collada/PMDConvert.cpp index 8a5554a1bd..744f51cc4b 100644 --- a/source/collada/PMDConvert.cpp +++ b/source/collada/PMDConvert.cpp @@ -21,7 +21,7 @@ #include #include -const int maxInfluences = 4; +const size_t maxInfluences = 4; struct VertexBlend { uint8 bones[maxInfluences]; diff --git a/source/collada/PSAConvert.cpp b/source/collada/PSAConvert.cpp index f80562da43..600f00d98f 100644 --- a/source/collada/PSAConvert.cpp +++ b/source/collada/PSAConvert.cpp @@ -73,7 +73,8 @@ public: FCDSkinController* skin = controller->GetSkinController(); // Find the first and last times which have animations - float timeStart = FLT_MAX, timeEnd = -FLT_MAX; + float timeStart = std::numeric_limits::max(); + float timeEnd = -std::numeric_limits::max(); for (size_t i = 0; i < skin->GetJointCount(); ++i) { FCDJointMatrixPair* joint = skin->GetJoint(i); diff --git a/source/collada/precompiled.h b/source/collada/precompiled.h index 315a450132..e5fdf012d4 100644 --- a/source/collada/precompiled.h +++ b/source/collada/precompiled.h @@ -12,7 +12,9 @@ extern void Log(int severity, const char* fmt, ...); #include "FCollada.h" #include "FCDocument/FCDocument.h" #include "FCDocument/FCDAnimated.h" +#include "FCDocument/FCDAnimatedCurve.h" #include "FCDocument/FCDController.h" +#include "FCDocument/FCDControllerInstance.h" #include "FCDocument/FCDGeometry.h" #include "FCDocument/FCDGeometryMesh.h" #include "FCDocument/FCDGeometryPolygons.h" diff --git a/source/graphics/MeshManager.cpp b/source/graphics/MeshManager.cpp index dc93ac33c8..1ea027e847 100644 --- a/source/graphics/MeshManager.cpp +++ b/source/graphics/MeshManager.cpp @@ -89,6 +89,7 @@ public: catch (PSERROR_DllLoader&) { LOG(ERROR, LOG_CATEGORY, "Failed to load symbols from COLLADA conversion DLL"); + dll.Unload(); return CModelDefPtr(); } diff --git a/source/graphics/tests/test_MeshManager.h b/source/graphics/tests/test_MeshManager.h index 6d3cacb8e3..a75b29b236 100644 --- a/source/graphics/tests/test_MeshManager.h +++ b/source/graphics/tests/test_MeshManager.h @@ -151,7 +151,7 @@ public: CModelDefPtr modeldef1 = meshManager->GetMesh(testPMD); CModelDefPtr modeldef2 = meshManager->GetMesh(testPMD); TS_ASSERT(modeldef1 && modeldef2); - TS_ASSERT_EQUALS(modeldef1.get(), modeldef2.get()); + if (modeldef1 && modeldef2) TS_ASSERT_EQUALS(modeldef1.get(), modeldef2.get()); } void test_load_dae() diff --git a/source/ps/DllLoader.cpp b/source/ps/DllLoader.cpp index 9800dc197f..8a701d437b 100644 --- a/source/ps/DllLoader.cpp +++ b/source/ps/DllLoader.cpp @@ -72,6 +72,15 @@ bool DllLoader::LoadDLL() return (m_Handle != HANDLE_UNAVAILABLE); } +void DllLoader::Unload() +{ + if (! IsLoaded()) + return; + + dlclose(m_Handle); + m_Handle = 0; +} + void DllLoader::LoadSymbolInternal(const char* name, void** fptr) const { if (! IsLoaded()) diff --git a/source/ps/DllLoader.h b/source/ps/DllLoader.h index 6050c19896..3c35524d07 100644 --- a/source/ps/DllLoader.h +++ b/source/ps/DllLoader.h @@ -33,6 +33,12 @@ public: * LoadDLL did. */ bool IsLoaded() const; + + /** + * Unload the library, if it has been loaded already. (Usually not needed, + * since the destructor will unload it.) + */ + void Unload(); /** * Attempt to load a named symbol from the library. If {@link #IsLoaded} is diff --git a/source/tools/atlas/AtlasUI/Misc/stdafx.h b/source/tools/atlas/AtlasUI/Misc/stdafx.h index e813008990..b4468398b4 100644 --- a/source/tools/atlas/AtlasUI/Misc/stdafx.h +++ b/source/tools/atlas/AtlasUI/Misc/stdafx.h @@ -70,7 +70,11 @@ #ifdef _WIN32 # define ATLASDLLIMPEXP extern "C" __declspec(dllexport) #else -# define ATLASDLLIMPEXP extern "C" +# if __GNUC__ >= 4 +# define ATLASDLLIMPEXP extern "C" __attribute__ ((visibility ("default"))) +# else +# define ATLASDLLIMPEXP extern "C" +# endif #endif // Abort with an obvious message if wx isn't Unicode, instead of complaining