Project

General

Profile

Bug #859

Compilation warning using Clang

Added by Davide Anastasia about 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
build
Target version:
Start date:
11 Oct 2012
Due date:
% Done:

100%

Estimated time:

Description

I am currently on Mac OS X 10.8.2 and using Clang 4.1/Apple (based on LLVM 3.1). One of exiv's header is giving me this warning:

/opt/local/include/exiv2/value.hpp:984:9: warning: attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration [-Wignored-attributes]
        EXIV2API struct Date
        ^
/opt/local/include/exiv2/exv_conf.h:245:20: note: expanded from macro 'EXIV2API'
#  define EXIV2API EXV_IMPORT
                   ^
/opt/local/include/exiv2/exv_conf.h:217:39: note: expanded from macro 'EXV_IMPORT'
#   define EXV_IMPORT __attribute__ ((visibility("default")))
                                      ^
1 warning generated.

I think the warning is quite self-explanatory.
Let me know if you need more help/tests.


Related issues

Related to Exiv2 - Bug #857: CMake compilation issue on MacOS-X 4.5.1/Mountain LionClosed07 Oct 2012

Actions

Associated revisions

Revision 2905 (diff)
Added by Robin Mills about 9 years ago

Fix: Issue: #859. Don't set visibility for clang compiler.

Revision 2906 (diff)
Added by Robin Mills about 9 years ago

Fix: Bug #859 (and #857). Redefine EXIV2_RCSID macro for clang as empty (to eliminate warnings).

Revision 2907 (diff)
Added by Andreas Huggel about 9 years ago

#859: Fixed position of visibility support macro.

History

#1

Updated by Robin Mills about 9 years ago

  • Category set to build
  • Assignee set to Robin Mills
  • Priority changed from Low to Normal
  • Target version set to 0.24

I'm surprised. I built this on Sunday and didn't notice anything like this. I see you're compiling from /opt/local/include/exiv2/value.hpp and I'm wondering if you're building with fink or MacPorts.

Can I suggest you get the code from the web site, or use svn to get the trunk. I personally always build in the directory ~/gnu/exiv2 - however the name isn't important. Use the usual recipe:

$ make config ; ./configure ; make ; sudo make install ; cd samples ; make ; cd ../test ; make test

Unfortunately, after upgrading to Mountain Lion last week, my Mac has decided to start crashing. Despite about 4 reloads of the OS this week, my system remains unusable at the moment.

#2

Updated by Davide Anastasia about 9 years ago

I am currently using MacPorts. I will try to build from source during the weekend and I will get back to you.

#3

Updated by Robin Mills about 9 years ago

David

I rebuilt my Mac. I formatted the disk and installed SnowLeopard from DVD, then downloaded/installed ML + Xcode + Apple's Command Line Tools (for make and such), SVN, CMake. I found this very helpful script for building the auto tools:

http://www.mattvsworld.com/blog/2010/02/install-the-latest-autoconf-and-automake-on-mac-os-10-6/

I also download/built/installed gettext:
http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.1.1.tar.gz
(this produced some errors which I ignored!)

I built the trunk with ./configure and cmake environments.
$ ./configure ; make ; sudo make install ; make samples LDFLAGS=-lexiv2 ; cd test ; make test

Two excuses:
1) Our test suite is currently failing our video tests (video is in development for 0.24)
2) I had to add the LDFLAGS to build the samples because I didn't have pkg-config built and installed.

The cmake environment ran well and the build passed our test suite. Of course the compiler generated the message which I reported in Bug #857 (which I hope to investigate later this weekend).

I also built our current 0.23 release with the ./configure approach.
You download it from http://exiv2.org/download.html http://exiv2.org/exiv2-0.23.tar.gz

$ cd exiv2-0.23
$ cd config && make -f config.make config
$ autoconf -o ../configure
$ cd .. ; chmod +x ./configure ; chmod +x config/*
$ make ; sudo make install
$ cd samples ; make LDFLAGS=-lexiv2
$ svn export svn://dev.exiv2.org/svn/tags/0.23/test
$ cd ../test ; make test

The test suite passes 100% (it has no video code!). Same excuse concerning LDFLAGS and pkg-config

I've tried to build pkg-config and ran into trouble.
I got the code here:

http://pkgconfig.freedesktop.org/releases/pkg-config-0.27.tar.gz
$ chmod +x ./configure ; ./configure --with-internal-glib
Rats:  It won't build because of the errors I ignored on gettext.

I'll think about this another day. This isn't an exiv2 issue.

#4

Updated by Robin Mills about 9 years ago

  • Status changed from New to Assigned

Installing pkg-config on Mountain Lion

I downloaded a pre-built version of pkg-config from http://iweb.dl.sourceforge.net/project/macpkg/PkgConfig/0.26/PkgConfig.pkg

This installed into /opt/pkgconfig/bin which I added to my path. You'll also need export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" (which I have already in my bash .profile file). Then samples built without the LDFLAGS=-lexiv2

And now to MacPorts

I downloaded and installed macports from http://www.macports.org/install.php. I asked him to build and install exiv2 and he worked perfectly.

394 rmills@rmills-imac:~/temp $ sudo port install exiv2
--->  Computing dependencies for exiv2
--->  Dependencies to be installed: expat gettext libiconv gperf ncurses zlib
--->  Fetching archive for expat
--->  Attempting to fetch expat-2.1.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/expat
--->  Attempting to fetch expat-2.1.0_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/expat
--->  Attempting to fetch expat-2.1.0_0.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/expat
--->  Fetching distfiles for expat
--->  Attempting to fetch expat-2.1.0.tar.gz from http://voxel.dl.sourceforge.net/project/expat/expat/2.1.0
--->  Verifying checksum(s) for expat
--->  Extracting expat
--->  Configuring expat
--->  Building expat
--->  Staging expat into destroot
--->  Installing expat @2.1.0_0
--->  Activating expat @2.1.0_0
--->  Cleaning expat
--->  Fetching archive for gperf
--->  Attempting to fetch gperf-3.0.4_2.darwin_12.x86_64.tbz2 from http://packages.macports.org/gperf
--->  Attempting to fetch gperf-3.0.4_2.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/gperf
--->  Attempting to fetch gperf-3.0.4_2.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/gperf
--->  Fetching distfiles for gperf
--->  Attempting to fetch gperf-3.0.4.tar.gz from http://distfiles.macports.org/gperf
--->  Verifying checksum(s) for gperf
--->  Extracting gperf
--->  Applying patches to gperf
--->  Configuring gperf
--->  Building gperf
--->  Staging gperf into destroot
--->  Installing gperf @3.0.4_2
--->  Activating gperf @3.0.4_2
--->  Cleaning gperf
--->  Fetching archive for libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/libiconv
--->  Attempting to fetch libiconv-1.14_0.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/libiconv
--->  Fetching distfiles for libiconv
--->  Attempting to fetch libiconv-1.14.tar.gz from http://distfiles.macports.org/libiconv
--->  Verifying checksum(s) for libiconv
--->  Extracting libiconv
--->  Applying patches to libiconv
--->  Configuring libiconv
--->  Building libiconv
--->  Staging libiconv into destroot
--->  Installing libiconv @1.14_0
--->  Activating libiconv @1.14_0
--->  Cleaning libiconv
--->  Fetching archive for ncurses
--->  Attempting to fetch ncurses-5.9_1.darwin_12.x86_64.tbz2 from http://packages.macports.org/ncurses
--->  Attempting to fetch ncurses-5.9_1.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/ncurses
--->  Attempting to fetch ncurses-5.9_1.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/ncurses
--->  Fetching distfiles for ncurses
--->  Attempting to fetch ncurses-5.9.tar.gz from http://distfiles.macports.org/ncurses
--->  Verifying checksum(s) for ncurses
--->  Extracting ncurses
--->  Applying patches to ncurses
--->  Configuring ncurses
--->  Building ncurses
--->  Staging ncurses into destroot
--->  Installing ncurses @5.9_1
--->  Activating ncurses @5.9_1
--->  Cleaning ncurses
--->  Fetching archive for gettext
--->  Attempting to fetch gettext-0.18.1.1_2.darwin_12.x86_64.tbz2 from http://packages.macports.org/gettext
--->  Attempting to fetch gettext-0.18.1.1_2.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/gettext
--->  Attempting to fetch gettext-0.18.1.1_2.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/gettext
--->  Fetching distfiles for gettext
--->  Attempting to fetch gettext-0.18.1.1.tar.gz from http://distfiles.macports.org/gettext
--->  Verifying checksum(s) for gettext
--->  Extracting gettext
--->  Applying patches to gettext
--->  Configuring gettext
--->  Building gettext
--->  Staging gettext into destroot
--->  Installing gettext @0.18.1.1_2
--->  Activating gettext @0.18.1.1_2
--->  Cleaning gettext
--->  Fetching archive for zlib
--->  Attempting to fetch zlib-1.2.7_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/zlib
--->  Attempting to fetch zlib-1.2.7_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/zlib
--->  Attempting to fetch zlib-1.2.7_0.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/zlib
--->  Fetching distfiles for zlib
--->  Attempting to fetch zlib-1.2.7.tar.bz2 from http://distfiles.macports.org/zlib
--->  Verifying checksum(s) for zlib
--->  Extracting zlib
--->  Configuring zlib
--->  Building zlib
--->  Staging zlib into destroot
--->  Installing zlib @1.2.7_0
--->  Activating zlib @1.2.7_0
--->  Cleaning zlib
--->  Fetching archive for exiv2
--->  Attempting to fetch exiv2-0.23_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/exiv2
--->  Attempting to fetch exiv2-0.23_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/exiv2
--->  Attempting to fetch exiv2-0.23_0.darwin_12.x86_64.tbz2 from http://lil.fr.packages.macports.org/exiv2
--->  Fetching distfiles for exiv2
--->  Attempting to fetch exiv2-0.23.tar.gz from http://distfiles.macports.org/exiv2
--->  Verifying checksum(s) for exiv2
--->  Extracting exiv2
--->  Configuring exiv2
--->  Building exiv2
--->  Staging exiv2 into destroot
--->  Installing exiv2 @0.23_0
--->  Activating exiv2 @0.23_0
--->  Cleaning exiv2
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.

395 rmills@rmills-imac:/opt $ find . -name exiv2
./local/bin/exiv2
./local/include/exiv2
./local/var/macports/distfiles/exiv2
./local/var/macports/software/exiv2
./local/var/macports/sources/rsync.macports.org/release/tarballs/ports/graphics/exiv2

396 rmills@rmills-imac:/opt $ /opt/local/bin/exiv2 -V
exiv2 0.23 001700 (64 bit build)
Copyright (C) 2004-2012 Andreas Huggel.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA

397 rmills@rmills-imac:/opt $ xcodebuild -version
Xcode 4.5.1
Build version 4G1004

398 rmills@rmills-imac:/opt $ sw_vers
ProductName:    Mac OS X
ProductVersion:    10.8.2
BuildVersion:    12C60

399 rmills@rmills-imac:/opt $ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Getting back to your original bug report

So, I'm not sure why you got the warnings you reported. Perhaps your path is causing you to pick up the wrong version of gcc or the autotools. We used to get the visibility warning on Cygwin and I documented the build procedure for that platform to be ./configure --disable-visibility. A few months ago, I changed config/configure.ac to set the visibility flag off by default on Cygwin.

I've assigned this issue to me. If you have additional information to add, please update this bug report and I will investigate.

#5

Updated by Robin Mills about 9 years ago

David

I've discovered something new about this. Issue#857 concerns warnings being produced by our CMake build on Mountain Lion. I discovered that the warnings were coming from the code being compiled by /usr/bin/c++ which is the Clang compiler. I added code to our CMakeLists.txt file to tell him to use the g++ compiler (/usr/bin/g++) which is GCC. Warnings disappear.

I see in the title of this bug report, you attributed these warning to clang and perhaps that's the explanation. Did you explicitly tell macports to use Clang?

Robin

#6

Updated by Davide Anastasia about 9 years ago

Sorry for the long waiting.

Macports: I haven't changed the default compiler in my MacPorts, so I am not exactly sure which one uses. cc by default on Mountain Lion points to Apple Clang 4.0 (a derivation of LLVM 3.1). I've done a simple "otool -L" of the built library in the /opt folder to check its dependencies, and it states:

/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)

Is this an hint GCC has been used for the compilation?

However, personal opinion, the problem with my compilation warning is not related with what the library was compiled with. I get this error while I compile the code of my project (Luminance HDR), and not while I compile exiv2, so the problem is in the header only somehow.

#7

Updated by Robin Mills about 9 years ago

Dave

Thanks for letting me know that this impacts your code and not only when building the library. I know what's wrong. The fix is in config/config.h.in and I've submitted SVN: 2905 to fix this.

To build with clang, I used the command:
$ make clean ; make config ; ./configure CXX=/usr/bin/c++

Using clang opens new compilation/linking issues which I haven't seen before. I'll hope to work on these later today. I know that clang can successfully build and link exiv2 because CMake builds (which use clang) have passed the test suite. I dealt with #857 yesterday by getting CMake builds to use the GCC compiler.

How to get the fix immediately (with rebuilding anything)

If you already have exiv2 built, you can put this fix into use by modifying exv_config.h (in /opt/local/include/exiv2 or /usr/local/include/exiv2)
Change (around line 215)

#  if defined(__GNUC__) && (__GNUC__ >= 4)
to
#  if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__clang__)

Determining the compiler

You can determine the version of the compiler used to build exiv2 with the command:

$ exiv2 -v -V # == --verbose --version

This is new (and still undocumented) for 0.24. It prints a list of libraries loaded at run-time AND information about the compiler. For example:

builder=GCC=4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00),DEBUG=0,DLL=1,Bits=8:
or
builder=GCC=4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66)),DEBUG=0,DLL=1,Bits=8:

The main information in the builder= strings is the VERSION macro defined at compile time.

#8

Updated by Andreas Huggel about 9 years ago

That looks like a bug, just one that no other compiler complained about so far. I've changed it, pls re-test.

andreas@Twinmate:~/src/exiv2/git/src$ grep EXIV2API *.hpp | grep struct
datasets.hpp:    struct EXIV2API RecordInfo {
datasets.hpp:    struct EXIV2API DataSet {
jpgimage.hpp:    struct EXIV2API Photosho {
preview.hpp:    struct EXIV2API PreviewProperties {
properties.hpp:    struct EXIV2API XmpPropertyInfo {
properties.hpp:    struct EXIV2API XmpNsInfo {
tags.hpp:    struct EXIV2API GroupInfo {
tags.hpp:    struct EXIV2API GroupInfo::GroupName {
tags.hpp:    struct EXIV2API TagInfo {
types.hpp:    struct EXIV2API DataBufRef {
types.hpp:    EXIV2API int exifTime(const char* buf, struct tm* tm);
value.hpp:        EXIV2API struct Date

-ahu.

#9

Updated by Andreas Huggel about 9 years ago

Robin, with r2907, can we undo r2905?

-ahu.

#10

Updated by Robin Mills about 9 years ago

Sure. No problem. I've submitted SVN: 2908.

#11

Updated by Robin Mills over 8 years ago

  • Target version changed from 0.24 to 0.25

Deferred to 0.25.

#12

Updated by Robin Mills about 7 years ago

  • Status changed from Assigned to Resolved

I'm going to mark this "resolved" as I haven't seen those warnings for a long time. I've just done a build on MacOS-X 10.9.5 with Xcode6. Both cmake and ./configure environments build cleanly without warnings.

668 rmills@rmillsmbp:~/gnu/exiv2/trunk $ sw_vers
ProductName:    Mac OS X
ProductVersion:    10.9.5
BuildVersion:    13F34
670 rmills@rmillsmbp:~/gnu/exiv2/trunk $ clang --version
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
671 rmills@rmillsmbp:~/gnu/exiv2/trunk $ 

#13

Updated by Robin Mills over 6 years ago

  • % Done changed from 0 to 100
#14

Updated by Andreas Huggel over 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF