example1.cpp clang Mac OS X warnings
|Status:||Closed||Start date:||23 Aug 2012|
|Assignee:||Robin Mills||% Done:|
The example at http://www.exiv2.org/example1.html prints some warnings with my compiler on Mac OS X.
bash-3.2$ c++ --version
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Thread model: posix
Warnings:bash-3.2$ c++ -lexiv2 -I /Users/jerry/Macports/include -L /Users/jerry/Macports/lib -o exifprint exifprint.cpp
In file included from exifprint.cpp:5:
In file included from /Users/jerry/Macports/include/exiv2/exiv2.hpp:35:
In file included from /Users/jerry/Macports/include/exiv2/bmpimage.hpp:34:
In file included from /Users/jerry/Macports/include/exiv2/exif.hpp:34:
In file included from /Users/jerry/Macports/include/exiv2/metadatum.hpp:39:
/Users/jerry/Macports/include/exiv2/value.hpp:984:9: warning: attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration
EXIV2API struct Date
/Users/jerry/Macports/include/exiv2/exv_conf.h:245:20: note: expanded from macro 'EXIV2API'
- define EXIV2API EXV_IMPORT
/Users/jerry/Macports/include/exiv2/exv_conf.h:217:39: note: expanded from macro 'EXV_IMPORT'
- define EXV_IMPORT attribute ((visibility("default")))
1 warning generated.
#1 Updated by Robin Mills over 4 years ago
- Status changed from New to Assigned
- Assignee set to Robin Mills
I recommend you build the sample applications and take a look at the arguments passed when he builds samples/exifprint
cd exiv2 ; make config ; ./configure ; make ; make samples
I suspect there are additional arguments you'll have to pass. You may have to export CC=c++ as I think ./configure uses g++ by default. I'm not too sure about the differences between the compilers gcc, g++ and c++. However the samples build and pass our test suite on MacOS-X/Lion (and other MacOS-X versions).
I'm away from my iMac today. I've assigned this issue to myself and I'll investigate later in the week when I have access to my iMac. Perhaps you could update this issue with any discoveries you make.
#2 Updated by Robin Mills over 4 years ago
Here's the transcript:
513 rmills@rmills-imac:~/gnu/exiv2/exiv2.master/samples $ touch exifprint.cpp ; make CC=c++
g++ -O2 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wcast-align -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Woverloaded-virtual -W -MMD `pkg-config exiv2 --cflags` -c -o exifprint.o exifprint.cpp
../libtool --mode=link g++ `pkg-config exiv2 --libs` -ldl -o exifprint exifprint.o
libtool: link: g++ -o exifprint exifprint.o -Wl,-bind_at_load -L/usr/local/lib /usr/local/lib/libexiv2.dylib -L/Users/rmills/gnu/exiv2/test.build/xmpsdk/src /usr/local/lib/libiconv.dylib -lz /usr/local/lib/libexpat.dylib -ldl
c++, g++ and gcc are all linked to the same file:
$ ls -alt `which c++`
lrwxr-xr-x 1 root wheel 12 Jun 13 22:31 /usr/bin/c++ -> llvm-g++-4.2
$ ls -alt `which g++`
lrwxr-xr-x 1 root wheel 12 Jun 13 22:31 /usr/bin/g++ -> llvm-g++-4.2
$ ls -alt `which gcc`
lrwxr-xr-x 1 root wheel 12 Jun 13 22:31 /usr/bin/gcc -> llvm-gcc-4.2
$ c++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.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.
ProductName: Mac OS X
If you're unhappy with this explanation, please voice your concern and I will investigate and respond. If you're happy with this explanation, may I ask you to change the status of the issue to closed.
#3 Updated by Robin Mills over 4 years ago
I built exiv2 from the trunk and installed it:
cd exiv2 ; make configure ; ./configure; make ; sudo make install
Compile/link exifprint.cpp (from http://www.exiv2.org/example1.html) is:
$ g++ exifprint.cpp -lexiv2 -o exifprint
I've tried a loop with g++, c++ and gcc. Although those are the same executable, gcc doesn't appear to link the C++ std run-time library.
$ for c in g++ c++ gcc; do rm
rf exifprint ; echo -- $c --- ; $c exifprint.cpp lexiv2 -o exifprint 2>&1 | head -2 ; ./exifprint ~/R.jpg | head -1 ; done g++ ---
Exif.Image.ImageDescription 0x010e Ascii 32
--- c++ ---
Exif.Image.ImageDescription 0x010e Ascii 32
--- gcc ---
Undefined symbols for architecture x86_64:
"std::cout", referenced from:
-bash: ./exifprint: No such file or directory