public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem compiling shared DLL with visibility attributes
@ 2009-07-17  9:18 Martin Kaiser
  2009-07-17 13:17 ` John (Eljay) Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kaiser @ 2009-07-17  9:18 UTC (permalink / raw)
  To: gcc-help

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==





^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Problem compiling shared DLL with visibility attributes
  2009-07-17  9:18 Problem compiling shared DLL with visibility attributes Martin Kaiser
@ 2009-07-17 13:17 ` John (Eljay) Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John (Eljay) Love-Jensen @ 2009-07-17 13:17 UTC (permalink / raw)
  To: Martin Kaiser, gcc-help

Hi Martin,

The Windows platform does not support visibility, since it isn't an ELF platform.  As per <http://gcc.gnu.org/wiki/Visibility>.

You will need to use a platform that has visibility support, such as (for examples) a BSD or Linux platform.

HTH,
--Eljay



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-17 13:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-17  9:18 Problem compiling shared DLL with visibility attributes Martin Kaiser
2009-07-17 13:17 ` John (Eljay) Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).