Author Topic: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)  (Read 4004 times)

Mentore

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 2
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Hello all.

I'm getting back to porting Qt programs, but I'm having troubles in linking. Here's the scenario: I decided to port Socializer (facebook QT browser) to try and have a native facebook browser native.

Being a Qt 5 application, I solved the JSON problem with an alternative library - works.

The program compiles but doesn't link. If I use -Zomf, the prelinker stops reporting a bunch of undetermined references, while using -Zexe it's g++ (ld) which stops saying it doesn't recognize the -O option. Needless to say, but there's no '-O' option in linker switches.

I also tried to

I attach here the makefile and the error messages reported. I'm currently using GCC 4.73, but the errors are the same. I even tried to delete all the -Z* linker options, and linking stops complaining it can't find the Qt libraries with errors like this:

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtGui4

or

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtWebKit4

but the library files (.lib files) are there. I'm really puzzled by this behavior. (Of course it's my ignorance on how gcc / ld work.)

Silvan Scherrer

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 9
  • Posts: 184
  • Karma: +1/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #1 on: June 19, 2015, 09:09:34 pm »
Hello all.

I'm getting back to porting Qt programs, but I'm having troubles in linking. Here's the scenario: I decided to port Socializer (facebook QT browser) to try and have a native facebook browser native.

Being a Qt 5 application, I solved the JSON problem with an alternative library - works.

The program compiles but doesn't link. If I use -Zomf, the prelinker stops reporting a bunch of undetermined references, while using -Zexe it's g++ (ld) which stops saying it doesn't recognize the -O option. Needless to say, but there's no '-O' option in linker switches.

I also tried to

I attach here the makefile and the error messages reported. I'm currently using GCC 4.73, but the errors are the same. I even tried to delete all the -Z* linker options, and linking stops complaining it can't find the Qt libraries with errors like this:

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtGui4

or

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtWebKit4

but the library files (.lib files) are there. I'm really puzzled by this behavior. (Of course it's my ignorance on how gcc / ld work.)
according to the error.txt it doesn't find the JSon stuff. did you add the library to link with -ljson.lib or such?
kind regards
Silvan
CTO bww bitwise works GmbH

Please help us with donations, so we can further work on OS/2 based projects. Our Shop is at https://www.bitwiseworks.com/shop/index.php

Mentore

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 2
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #2 on: June 19, 2015, 10:14:56 pm »
Hello all.

I'm getting back to porting Qt programs, but I'm having troubles in linking. Here's the scenario: I decided to port Socializer (facebook QT browser) to try and have a native facebook browser native.

Being a Qt 5 application, I solved the JSON problem with an alternative library - works.

The program compiles but doesn't link. If I use -Zomf, the prelinker stops reporting a bunch of undetermined references, while using -Zexe it's g++ (ld) which stops saying it doesn't recognize the -O option. Needless to say, but there's no '-O' option in linker switches.

I also tried to

I attach here the makefile and the error messages reported. I'm currently using GCC 4.73, but the errors are the same. I even tried to delete all the -Z* linker options, and linking stops complaining it can't find the Qt libraries with errors like this:

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtGui4

or

U:/usr/i386-pc-os2-emx/bin/ld.exe: No such file or directory for QtWebKit4

but the library files (.lib files) are there. I'm really puzzled by this behavior. (Of course it's my ignorance on how gcc / ld work.)

according to the error.txt it doesn't find the JSon stuff. did you add the library to link with -ljson.lib or such?

I know it seems so, but still - the software package I used to allow the JSon functionalities does not contain a library. Indeed I have to investigate further this issue, but even the documentation does not talk about a library file.

EDIT: indeed I must have eaten my brains in a moment of hunger!!!  :o I included the header and cpp files, but did not modify the .pro file to compile the .cpp files. I'm feeling such an idiot now...

I'm afraid I'm getting too used to fancy IDEs and similar. Ok, back to work. Thank you! I'll report my results eventually.

Mentore
« Last Edit: June 19, 2015, 10:19:16 pm by Mentore »

Mentore

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 2
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #3 on: June 19, 2015, 11:02:53 pm »
EDIT: indeed I must have eaten my brains in a moment of hunger!!!  :o I included the header and cpp files, but did not modify the .pro file to compile the .cpp files. I'm feeling such an idiot now...

I'm afraid I'm getting too used to fancy IDEs and similar. Ok, back to work. Thank you! I'll report my results eventually.

Mentore

Aaaaannnd... It worked! Socializer.exe is up and running. And it does quite an interesting job, though it seems unable to load images. Nevermind, it's still a nice step forward in creating new OS/2 software. This makes my evening :)

Mentore

ivan

  • Hero Member
  • *****
  • Thank You
  • -Given: 2
  • -Receive: 51
  • Posts: 1301
  • Karma: +12/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #4 on: June 20, 2015, 01:04:24 am »
Hi Mentore,

If you are looking for something to port maybe you could look at Sigil an epub production tool/editor.  As far as I know the last version that used Qt4 was v0.6.2 (I got the source code in case it was deleted as being too old).

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 13
  • -Receive: 208
  • Posts: 2992
  • Karma: +38/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #5 on: June 20, 2015, 03:44:32 am »
Hi Mentore,
Quote
The program compiles but doesn't link. If I use -Zomf, the prelinker stops reporting a bunch of undetermined references, while using -Zexe it's g++ (ld) which stops saying it doesn't recognize the -O option. Needless to say, but there's no '-O' option in linker switches.

The rule is that you need to link with -Zomf to pull in OMF libraries which usually have a .lib suffix. With kLIBC -Zomf will also pull in aout libraries (.a suffix). As QT is an OMF build you will always need to at least add -Zomf to LDFLAGS.
-Zexe is hardly ever useful now a days and was introduced for those cases where a *nix makefile targets foo instead of foo.exe. It's better to add $(exeext) to the makefile if needed but most build systems can figure this out due to Windows also needing it. Using -Zomf also seems to create a correct executable with the .exe extension.
The error about -O is part of the command that GCC creates to call LD.

Mentore

  • Jr. Member
  • **
  • Thank You
  • -Given: 17
  • -Receive: 2
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: [Qt ports] Can't understand linking problem (-Zexe / -Zomf)
« Reply #6 on: June 20, 2015, 11:53:41 am »
Hi Mentore,
Quote
The program compiles but doesn't link. If I use -Zomf, the prelinker stops reporting a bunch of undetermined references, while using -Zexe it's g++ (ld) which stops saying it doesn't recognize the -O option. Needless to say, but there's no '-O' option in linker switches.

The rule is that you need to link with -Zomf to pull in OMF libraries which usually have a .lib suffix. With kLIBC -Zomf will also pull in aout libraries (.a suffix). As QT is an OMF build you will always need to at least add -Zomf to LDFLAGS.
-Zexe is hardly ever useful now a days and was introduced for those cases where a *nix makefile targets foo instead of foo.exe. It's better to add $(exeext) to the makefile if needed but most build systems can figure this out due to Windows also needing it. Using -Zomf also seems to create a correct executable with the .exe extension.
The error about -O is part of the command that GCC creates to call LD.

Thanks Dave and all of you. As said before, the problem was solved reworking the .pro file to include all the JSON files. Socializer works a little bad so I consider it a "no-way", but still this confirms I can build Qt GUI programs. By the way, yesterday evening I was able to compile cpik (PIC microcontroller programming software under Qt) which is a VIO software, so it seems everything works fine.

Mentore