2010.05.02 01:54 "[Tiff] qmake (Qt) and libtiff "undefined symbols" problem on mac (snow leopard).", by Dave Sun

2010.05.02 12:25 "Re: [Tiff] qmake (Qt) and libtiff "undefined symbols" problem on mac (snow leopard).", by Toby Thain

On 2-May-10, at 9:39 PM, Dave wrote:

> Hi Chris,

> Can you provide some more info on how to build libtiff on my 64 bit > machine? I could not find the options in the "configure" step.

>

If you are building libtiff from source, by default it will build for a single architecture (build host's). If you obtained a binary library from somewhere else, then as Chris says, it may simply not include the needed architecture.

Perhaps Qt Creator is setting architecture options for your application's objects? (I know nothing about Qt Creator.) Check the exact compile commands being used, and/or project settings.

You might find `lipo -info` or `file` handy here (see below).

--Toby

$ lipo -info /usr/local/lib/libgd.a input file /usr/local/lib/libgd.a is not a fat file Non-fat file: /usr/local/lib/libgd.a is architecture: ppc7400

$ lipo -info /usr/lib/libcrypto.dylib Architectures in the fat file: /usr/lib/libcrypto.dylib are: ppc7400 ppc64 i386 x86_64

> On Sat, May 1, 2010 at 10:51 PM, Chris Cox <ccox@adobe.com> wrote:

> The important line would be "ld: warning: in /usr/local/lib/ > libtiff.dylib, file is not of required architecture"

You have a libtiff that isn't compiled for your architecture.

(probably 32 bit when you need 64, or vice versa)

________________________________________

> From: tiff-bounces@lists.maptools.org [tiff-
> bounces@lists.maptools.org] On Behalf Of Dave Sun [hotdog.sun@gmail.com
> ]

Dear folks,

I have problems using qmake to compile my simplest libtiff program. Here are the information about my system.

computer: Darwin Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386 Qt version: Qt 4.6.2

libtiff version: 3.9.2
operating system: snow leopard.

Simplest program:

#include <QtCore/QCoreApplication>
#include "tiff.h"
#include "tiffio.h"
#include <iostream>

int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);
    TIFF* tif = TIFFOpen("foo.tif", "r");
    if(tif == NULL)
       std::cout << "could not open the file";
    TIFFClose(tif);
    //return a.exec();
std::cout << "hello";
    return 0;
}

my pro file:

QT -= gui
TARGET = libtiffSimpleTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
LIBS += -ltiff
SOURCES += main.cpp

I used Qt creator as my IDE. When I run compiling program I got the following error:

ld: warning: in /usr/local/lib/libtiff.dylib, file is not of required architecture

Undefined symbols:

"_TIFFOpen", referenced from:

_main in main.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

make: *** [libtiffSimpleTest] Error 1

However, when I just use the following:

g++ main.cpp -ltiff

It works well. What is the problem here?