Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, January 2008
Running fresh app on MacOSX


Message 1 in thread

Hi Trolls,

Quite new to programming with Qt on MacOSX and running into troubles  
already.

I have an application build with plugins (shared libs) and I was able  
to compile and link it. When I try to run the application, I'm treated  
to the following message...

--[ Message ]--

qtimetrack.app/Contents/MacOS/qtimetrack
dyld: Library not loaded: liblog4cpp.1.dylib
   Referenced from: /Users/pgroen/projects/qtimetrack/build/ 
qtimetrack.app/Contents/MacOS/qtimetrack
   Reason: image not found
Trace/BPT trap

--[ /Message ]--

I have to tell the DESTDIR for my application is build and the libs  
are one level below  under lib.
I fiure it is normal under MacOSX to create a directory structure for  
the application. I only wonder how I can tell my application it has to  
look for the libs in a different place than expected (Where ever that  
may be). Not really a Qt-question, I know, but it is somewhat  
related.. (I hope)

Kind regards,

Peter M. Groen
Open Systems Development
Klipperwerf 12
2317 DZ  Leiden
Tel   : +31-(0)71-5216317
Mobile: +31-(0)6-29563390
Email : pgroen@xxxxxxxx
Skype : peter_m_groen

--
 [ signature omitted ] 

Message 2 in thread

On 5 jan 2008, at 01:35, Peter Groen wrote:

> Hi Trolls,
>
> Quite new to programming with Qt on MacOSX and running into troubles  
> already.
>
> I have an application build with plugins (shared libs) and I was  
> able to compile and link it. When I try to run the application, I'm  
> treated to the following message...
>
> --[ Message ]--
>
> qtimetrack.app/Contents/MacOS/qtimetrack
> dyld: Library not loaded: liblog4cpp.1.dylib
>  Referenced from: /Users/pgroen/projects/qtimetrack/build/ 
> qtimetrack.app/Contents/MacOS/qtimetrack
>  Reason: image not found
> Trace/BPT trap
>
> --[ /Message ]--
>
> I have to tell the DESTDIR for my application is build and the libs  
> are one level below  under lib.
> I fiure it is normal under MacOSX to create a directory structure  
> for the application. I only wonder how I can tell my application it  
> has to look for the libs in a different place than expected (Where  
> ever that may be). Not really a Qt-question, I know, but it is  
> somewhat related.. (I hope)
>
> Kind regards,
>
> Peter M. Groen
> Open Systems Development
> Klipperwerf 12
> 2317 DZ  Leiden
> Tel   : +31-(0)71-5216317
> Mobile: +31-(0)6-29563390
> Email : pgroen@xxxxxxxx
> Skype : peter_m_groen
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/


Kay.. Problems always get in my hair (If I had any :S ) so I tried to  
copy all the libs into the directory where the <applicationame>.app  
directory exist. And guess? It works.

But I still want to figure out if it is possible to use custom dirs  
for home-baked directories. If I have the time, I'll try to do  
something with LD_LIBRARY_PATH or something more BSD-like :)

Thanx for now.

Peter M. Groen
Open Systems Development
Klipperwerf 12
2317 DZ  Leiden
Tel   : +31-(0)71-5216317
Mobile: +31-(0)6-29563390
Email : pgroen@xxxxxxxx
Skype : peter_m_groen

--
 [ signature omitted ] 

Message 3 in thread

Hi Michael,

Thanx. I'll give it a try.

On 5 jan 2008, at 21:13, Michael Rice wrote:

> On OS X, you can use DYLD_LIBRARY_PATH environment variable just as  
> you would use LD_LIBRARY_PATH on Linux.
>
> On Jan 5, 2008, at 8:03 AM, Peter Groen wrote:
>
>>
>> On 5 jan 2008, at 01:35, Peter Groen wrote:
>>
>>> Hi Trolls,
>>>
>>> Quite new to programming with Qt on MacOSX and running into  
>>> troubles already.
>>>
>>> I have an application build with plugins (shared libs) and I was  
>>> able to compile and link it. When I try to run the application,  
>>> I'm treated to the following message...
>>>
>>> --[ Message ]--
>>>
>>> qtimetrack.app/Contents/MacOS/qtimetrack
>>> dyld: Library not loaded: liblog4cpp.1.dylib
>>> Referenced from: /Users/pgroen/projects/qtimetrack/build/ 
>>> qtimetrack.app/Contents/MacOS/qtimetrack
>>> Reason: image not found
>>> Trace/BPT trap
>>>
>>> --[ /Message ]--
>>>
>>> I have to tell the DESTDIR for my application is build and the  
>>> libs are one level below  under lib.
>>> I fiure it is normal under MacOSX to create a directory structure  
>>> for the application. I only wonder how I can tell my application  
>>> it has to look for the libs in a different place than expected  
>>> (Where ever that may be). Not really a Qt-question, I know, but it  
>>> is somewhat related.. (I hope)
>>>
>>> Kind regards,
>>>
>>> Peter M. Groen
>>> Open Systems Development
>>> Klipperwerf 12
>>> 2317 DZ  Leiden
>>> Tel   : +31-(0)71-5216317
>>> Mobile: +31-(0)6-29563390
>>> Email : pgroen@xxxxxxxx
>>> Skype : peter_m_groen
>>>
>>> --
>>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
>>> with "unsubscribe" in the subject or the body.
>>> List archive and information: http://lists.trolltech.com/qt- 
>>> interest/
>>
>>
>> Kay.. Problems always get in my hair (If I had any :S ) so I tried  
>> to copy all the libs into the directory where the  
>> <applicationame>.app directory exist. And guess? It works.
>>
>> But I still want to figure out if it is possible to use custom dirs  
>> for home-baked directories. If I have the time, I'll try to do  
>> something with LD_LIBRARY_PATH or something more BSD-like :)
>>
>> Thanx for now.
>>
>> Peter M. Groen
>> Open Systems Development
>> Klipperwerf 12
>> 2317 DZ  Leiden
>> Tel   : +31-(0)71-5216317
>> Mobile: +31-(0)6-29563390
>> Email : pgroen@xxxxxxxx
>> Skype : peter_m_groen
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>

Peter M. Groen
Open Systems Development
Klipperwerf 12
2317 DZ  Leiden
Tel   : +31-(0)71-5216317
Mobile: +31-(0)6-29563390
Email : pgroen@xxxxxxxx
Skype : peter_m_groen

--
 [ signature omitted ] 

Message 4 in thread

On 2008-01-04 19:35:09 -0500, Peter Groen <pgroen@xxxxxxxx> said:

> Hi Trolls,
> 
> Quite new to programming with Qt on MacOSX and running into troubles  already.
> 
> I have an application build with plugins (shared libs) and I was able  
> to compile and link it. When I try to run the application, I'm treated  
> to the following message...
> 
> --[ Message ]--
> 
> qtimetrack.app/Contents/MacOS/qtimetrack
> dyld: Library not loaded: liblog4cpp.1.dylib
>    Referenced from: /Users/pgroen/projects/qtimetrack/build/ 
> qtimetrack.app/Contents/MacOS/qtimetrack
>    Reason: image not found
> Trace/BPT trap
> 
> --[ /Message ]--
> 
> I have to tell the DESTDIR for my application is build and the libs  
> are one level below  under lib.
> I fiure it is normal under MacOSX to create a directory structure for  
> the application. I only wonder how I can tell my application it has to  
> look for the libs in a different place than expected (Where ever that  
> may be). Not really a Qt-question, I know, but it is somewhat  
> related.. (I hope)
> 
> Kind regards,
> 
> Peter M. Groen
> Open Systems Development
> Klipperwerf 12
> 2317 DZ  Leiden
> Tel   : +31-(0)71-5216317
> Mobile: +31-(0)6-29563390
> Email : pgroen@xxxxxxxx
> Skype : peter_m_groen

Take a look in QtAssistant for the following topic: Deploying an 
Application on Qt/Mac and Qt/Mac-specific issues.

Basically the rpath (in linux parlance) or the "install_name" (in OS X 
parlance) is stored within the library itself. This way the linker can 
link everything together and there (in theory) is no need some 
DYLD_LIBRARY_PATH and other such things. In real life things are 
different.

First, run a terminal program called "otool" with the -L argument and 
the path to the  liblog4cpp.1.dylib library. What this tells you is the 
"install_name" that is stored in the library. Your library has JUST the 
name of the library which means you have to set the DYLD_LIBRARY_PATH 
or have the library in the same directory as the executable.

Now, what is normally done on OS X is to set a "special" install_name 
in the library then COPY the library is a location within the 
Application Bundle. So here we go.

install_name_tool -id @executable_path/../lib/liblog4cpp.1.dylib 
[absolute path to the log4cpp library]
That _should_ work. There may be an instance where it will NOT work. If 
it does not work then write back to the list for further instructions.

Now check the library again with otool -L and see that the install_name 
has indeed been changed.

Now relink/recompile you program against this new library.

Run otool -L /Users/pgroen/projects/qtimetrack/build/ 
qtimetrack.app/Contents/MacOS/qtimetrack
You should see that qtimetrack is now looking for log4cpp in the 
@executable_path/../lib/ location.

Lastly, create the following directory:
/Users/pgroen/projects/qtimetrack/build/ qtimetrack.app/Contents/lib  
and copy the log4cpp library into that directory.

Launch your application normally from the gui. It should now work just fine.

Repeat for EVERY 3rd party library you use, including Qt.

Of course most people start writing shell scripts to do all the after a 
successful compile. If you happen to be using CMake instead of QMake I 
have some scripts that you can copy from.

Hope all this helps
Mike Jackson
OS X Build specialist.

--
 [ signature omitted ] 

Message 5 in thread

On 7 jan 2008, at 18:52, Mike Jackson wrote:
>
> Take a look in QtAssistant for the following topic: Deploying an  
> Application on Qt/Mac and Qt/Mac-specific issues.
>
> Basically the rpath (in linux parlance) or the "install_name" (in OS  
> X parlance) is stored within the library itself. This way the linker  
> can link everything together and there (in theory) is no need some  
> DYLD_LIBRARY_PATH and other such things. In real life things are  
> different.
>
> First, run a terminal program called "otool" with the -L argument  
> and the path to the  liblog4cpp.1.dylib library. What this tells you  
> is the "install_name" that is stored in the library. Your library  
> has JUST the name of the library which means you have to set the  
> DYLD_LIBRARY_PATH or have the library in the same directory as the  
> executable.
>
> Now, what is normally done on OS X is to set a "special"  
> install_name in the library then COPY the library is a location  
> within the Application Bundle. So here we go.
>
> install_name_tool -id @executable_path/../lib/liblog4cpp.1.dylib  
> [absolute path to the log4cpp library]
> That _should_ work. There may be an instance where it will NOT work.  
> If it does not work then write back to the list for further  
> instructions.
>
> Now check the library again with otool -L and see that the  
> install_name has indeed been changed.
>
> Now relink/recompile you program against this new library.
>
> Run otool -L /Users/pgroen/projects/qtimetrack/build/ qtimetrack.app/ 
> Contents/MacOS/qtimetrack
> You should see that qtimetrack is now looking for log4cpp in the  
> @executable_path/../lib/ location.
>
> Lastly, create the following directory:
> /Users/pgroen/projects/qtimetrack/build/ qtimetrack.app/Contents/ 
> lib  and copy the log4cpp library into that directory.
>
> Launch your application normally from the gui. It should now work  
> just fine.
>
> Repeat for EVERY 3rd party library you use, including Qt.
>
> Of course most people start writing shell scripts to do all the  
> after a successful compile. If you happen to be using CMake instead  
> of QMake I have some scripts that you can copy from.
>
> Hope all this helps
> Mike Jackson
> OS X Build specialist.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/


Hi Mike,

Thank you for your extended answer. This was exactly the information I  
was looking for. I asked this question also on the Xcode developers  
list and frankly, I'm still waiting for an answer. The best I got  
was : "Try use the Xcode environment instead of qmake / make".

I'm abit ashamed of the RTFM-part of the answer. I should've thought  
of Qt-assistant earlier...

Again: Thanx. I'll have something to study on again.
Any results will be posted on my personal blog (http://blog.osdev.nl)

Kind regards,

Peter M. Groen
Open Systems Development
Klipperwerf 12
2317 DZ  Leiden
Tel   : +31-(0)71-5216317
Mobile: +31-(0)6-29563390
Email : pgroen@xxxxxxxx
Skype : peter_m_groen

--
 [ signature omitted ]