From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17320 invoked by alias); 17 Jul 2009 09:18:46 -0000 Received: (qmail 17305 invoked by uid 22791); 17 Jul 2009 09:18:45 -0000 X-SWARE-Spam-Status: No, hits=1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.uni-paderborn.de (HELO mail.uni-paderborn.de) (131.234.142.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Jul 2009 09:18:39 +0000 Received: from i59f578a8.versanet.de ([89.245.120.168] helo=[192.168.178.44]) by mail.uni-paderborn.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63 hoth) id 1MRjaN-0000q8-S8 for gcc-help@gcc.gnu.org; Fri, 17 Jul 2009 11:18:36 +0200 Message-ID: <4A6041EA.50700@uni-paderborn.de> Date: Fri, 17 Jul 2009 09:18:00 -0000 From: Martin Kaiser User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Problem compiling shared DLL with visibility attributes Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kaiserm,ou=People,o=upb,c=de Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00282.txt.bz2 hi, I want to create a shared Library with the new gcc's visibility features as desribed in http://gcc.gnu.org/wiki/Visibility . For every member in my classes I get a warning like: g++ -O0 -g3 -Wall -c -fmessage-length=0 -fvisibility=hidden -oA.o ..\A.cpp ..\A.cpp: In member function 'void A::foo()': ..\A.cpp:17: warning: visibility attribute not supported in this configuration; ignored Working with Windows XP, tdm-mingw-1.905.0-4.4.0-2, and eclipse gallileo with cdt (yep! ...Just started programming...). Any thoughts? Thanks in advance ==CompilerSettings.h== #ifndef COMPILERSETTINGS_H #define COMPILERSETTINGS_H // @see http://gcc.gnu.org/wiki/Visibility for details // Generic helper definitions for shared library support #ifdef _MSC_VER // Windows && MS Visual C #if _MSC_VER < 1310 //Version < 7.1? #pragma message ("Compiling with a Visual C compiler version < 7.1 (2003) has not been tested!") #endif // Version > 7.1 #define TESTLIB_HELPER_DLL_IMPORT __declspec(dllimport) #define TESTLIB_HELPER_DLL_EXPORT __declspec(dllexport) #define TESTLIB_HELPER_DLL_LOCAL #else #if __GNUC__ >= 4 #define TESTLIB_HELPER_DLL_IMPORT __attribute__ ((visibility("default"))) #define TESTLIB_HELPER_DLL_EXPORT __attribute__ ((visibility("default"))) #define TESTLIB_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden"))) #else #define TESTLIB_HELPER_DLL_IMPORT #define TESTLIB_HELPER_DLL_EXPORT #define TESTLIB_HELPER_DLL_LOCAL #endif #endif // Now we use the generic helper definitions above to define TESTLIB_API and TESTLIB_LOCAL. // TESTLIB_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build) // TESTLIB_LOCAL is used for non-api symbols. #ifdef TESTLIB_DLL // defined if TESTLIB is compiled as a DLL #ifdef TESTLIB_DLL_EXPORTS // defined if we are building the TESTLIB DLL (instead of using it) #define DLL_PUBLIC TESTLIB_HELPER_DLL_EXPORT #else #define DLL_PUBLIC TESTLIB_HELPER_DLL_IMPORT #endif // TESTLIB_DLL_EXPORTS #define DLL_LOCAL TESTLIB_HELPER_DLL_LOCAL #else // TESTLIB_DLL is not defined: this means TESTLIB is a static lib. #define DLL_PUBLIC #define DLL_LOCAL #endif // TESTLIB_DLL #endif //COMPILERSETTINGS_H ==CompilerSettings.h== ==A.h== #ifndef A_H_ #define A_H_ #define TESTLIB_DLL #define TESTLIB_DLL_EXPORTS #include "CompilerSettings.h" class DLL_PUBLIC A { public: A(); virtual ~A(); DLL_LOCAL void foo(); DLL_PUBLIC void bar(); }; #endif /* A_H_ */ ==A.h== ==A.cpp== #include "A.h" A::A() {} A::~A() {} void A::foo() {} void A::bar() {} ==A.cpp== ==FULL eclipse Ouput== **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -fvisibility=hidden -oA.o ..\A.cpp ..\A.cpp: In member function 'void A::foo()': ..\A.cpp:17: warning: visibility attribute not supported in this configuration; ignored g++ -shared -Wl,--out-implib=libTestVisibility.a -olibtestVisibility.dll A.o Creating library file: libTestVisibility.a Build complete for project testVisibility Time consumed: 4547 ms. ==FULL eclipse Ouput==