This is a discussion on g++: using visibility attrib w/ explicit template instances within the Coding in General forums, part of the Development/Scripting category; I hope this thread is appropriate for this forum. I recently began using the visibility attribute now available in gcc. ...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
I hope this thread is appropriate for this forum.
I recently began using the visibility attribute now available in gcc. The software I am working on is proprietary (my employer pays the bills I cannot seem to get this template class working with g++ and its visibility attribute. Below is much simplified example that demonstrates my problem. Environment is Ubuntu Dapper, g++ version 4.0.3, kernel version 2.6.15-27-686. Error message: ---------------------- Code:
/tmp/ccsVuuf1.o: In function `main':TestMain.cpp:(.text+0x33): undefined reference to `TestClass::test(double const&) const' collect2: ld returned 1 exit status ------------------------ Code:
g++ -c -O3 -fpic -fvisibility=hidden -fvisibility-inlines-hidden -std=c++98 -pedantic TestClass.cpp g++ -shared -o libTestClass.so TestClass.o g++ -o TestMain TestMain.cpp -L. -lTestClass --------------------- Code:
#ifndef HPP_TESTCLASS
#define HPP_TESTCLASS
template
class __attribute__ ((visibility("default"))) TestClass
{
public:
bool test(_Tp const& x) const;
};
#endif
--------------------- Code:
#include "TestClass.hpp"
#include
template
bool
TestClass::
test(_Tp const& x) const
{ return typeid(x) == typeid(_Tp); }
template class __attribute__ ((visibility("default"))) TestClass;
------------------- Code:
#include "TestClass.hpp"
int main()
{
TestClass t;
t.test();
return 0;
}
-Matthew- |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|