none of fink macports and homebrew useful on lion? - xcode4

I have an library (flam3) that depends on a few utility libraries from unix (xml2, jpeg, png, z) and I am trying to make an application on Lion that uses it. I am building with the latest Xcode and when I try to link with the libraries from fink, macports, and homebrew I get the same error:
ld: warning: ignoring file /opt/local/lib/libxml2.a, file was built
for archive which is not the architecture being linked (i386)
and the libraries look different from ones that work:
bash-3.2$ file /sw/lib/libxml2.a
/sw/lib/libxml2.a: current ar archive random library
by comparision
bash-3.2$ file ~/Documents/FLAM3/libflam3.a
/Users/spot/Documents/FLAM3/libflam3.a: Mach-O universal binary with 2
architectures
/Users/spot/Documents/FLAM3/libflam3.a (for architecture x86_64):
current ar archive random library
/Users/spot/Documents/FLAM3/libflam3.a (for architecture i386):
current ar archive random library
that's the library that I compiled with Xcode.
Is there any way to get Xcode to accept this library? Is there any way to get fink/macports/homebrew to generate a library that works with Xcode? Seems like I am "doing it wrong" as these projects would all be useless if everyone had this problem.... but I don't feel like I've done anything unusual. Help?

The problem is that your libxml2.a is not built as "Universal binary". I.e. it doesn't contain all necessary architectures (In your case I believe it is i386). You need to ask fink, macports, or homebrew to build/download/install library with all necessary platforms. I know that macports has such flag (I don't remember how it's called).
The "file" command list all available architectures for .a file only when the file is trully universal (contains two or more of ppc, i386, x86_64), otherwise it only shows the vanilla "ar archive..." message. That confirms your libxml2.a has only one architecture.
The problem is not in Xcode or Lion. Possibly the default link architecture on Lion changed.

Related

How install qt libraries near to executable file

There was such a problem: using cmake to install the compiled executable in a certain directory, along with all the dependent libraries (qt), so that later this folder could be simply transferred to another computer, with the same architecture (and installed packages, like built-essential). And do it on two systems: linux & windows. And there are two problems:
what are the dependencies of Qt libraries and how to identify them with cmake (if it possible)?
when using install(FILES $<TARGET_FILE:Qt5::some_packet> DESTINATION bin) on Linux, the following libraries will be copied: libQt5some_packet.so.5.11.1 and when you try to start the program, it will immediately declare that it cannot find the corresponding libraries. And the command export LD_LIBRARY_PATH=/install path/bin haven't any result.
UDP i find how fix problem 2:
install(FILE $<TARGET_SONAME_FILE:Qt::some_package> DESTINATION bin)
but first problem (for windows) is open.
You can use Dependency Walker to get the complete list of dll dependencies

Compiling Dolphin emulator beta

Moved from here, because it's about compiling software.
My original problem: I want to play Super Mario Galaxy 2 with another player. But whatever keys I assign to move the cursor, it instead moves it all the way to the corner (or edge) of the screen. Linux theoretically has the ability to have multiple cursors (at least the display system "X" allows it), but from a research it looks like I would have to make major changes to the system to actually use it. And even then I doubt that Dolphin would support it.
My current problem: Relative motion of a cursor from keys is present in the current betas of Dolphin, but I can't get it installed. There are no regular installers for it, instead there are source downloads and this tutorial.
I installed the dependencies, downloaded the beta, created and entered the "Build" directory, but when I try cmake .., I get this output:
-- Detected architecture: x86_64
-- X11 support enabled
-- Xrandr found
-- Found avcodec: /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libavcodec.so
-- Found avformat: /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libavformat.so
-- Found avutil: /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libavutil.so
-- Found swresample: /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libswresample.so
-- Found swscale: /usr/include/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libswscale.so
-- libav/ffmpeg found, enabling AVI frame dumps
-- libevdev/libudev found, enabling evdev controller backend
-- Using named pipes as controller inputs
-- Watching game memory for changes
-- Enabling analytics collection (subject to end-user opt-in)
-- Using static enet from Externals
-- Using static xxhash from Externals
-- Using shared zlib
-- Using static lzo from Externals
-- Using shared libpng
-- Using shared LibUSB
-- Found SFML 2.4 in /usr/include
-- Using shared SFML
-- Using shared miniupnpc
-- Could NOT find MBEDTLS (missing: MBEDTLS_VERSION_OK)
-- Using static mbed TLS from Externals
-- Using shared libcurl
-- Using static DiscordRPC from Externals
-- libsystemd found, enabling traversal server watchdog support
-- Using static gtest from Externals
-- Could NOT find OpenSLES (missing: OPENSLES_LIBRARY OPENSLES_INCLUDE_DIR)
-- ALSA found, enabling ALSA sound backend
-- PulseAudio found, enabling PulseAudio sound backend
-- BlueZ found, enabling bluetooth support
CMake Error at Source/Core/DolphinQt/CMakeLists.txt:1 (find_package):
Could not find a configuration file for package "Qt5" that is compatible
with requested version "5.9".
The following configuration files were considered but not accepted:
/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake, version: 5.7.1
-- Configuring incomplete, errors occurred!
See also "/home/fabian/dolphin_beta/dolphin-emu/Build/CMakeFiles/CMakeOutput.log".
See also "/home/fabian/dolphin_beta/dolphin-emu/Build/CMakeFiles/CMakeError.log".
The output of apt-file search Qt5Config.cmake is:
libaccounts-qt5-dev: /usr/lib/x86_64-linux-gnu/cmake/AccountsQt5/AccountsQt5Config.cmake
libphonon4qt5-dev: /usr/lib/x86_64-linux-gnu/cmake/phonon4qt5/Phonon4Qt5Config.cmake
libsignon-qt5-dev: /usr/lib/x86_64-linux-gnu/cmake/SignOnQt5/SignOnQt5Config.cmake
libtelepathy-qt5-dev: /usr/lib/x86_64-linux-gnu/cmake/TelepathyQt5/TelepathyQt5Config.cmake
qtbase5-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake
To be safe I installed all five of these packages. I also installed version 5.10 of Qt5-default from here, later also 5.11. I also installed qtbase5-private-dev, libreadline-dev and tried to install libpolarssl-dev, but the page gave error messages for all four servers (the Taiwanian one just loads forever, the others give 404). Then I tried the Qt installer and selected the latest stable version (5.11 I think) once and 5.9 once.
None of these steps helped, I still get the same output as at the beginning.
Here is a copy of CMakeOutput.log from when I last tried installing: https://pastebin.com/EP5qDGE9
Here is a copy of CMakeError.log from when I last tried installing: https://pastebin.com/9p4Ni0jE
My specs:
Debian 9.5
Cinnamon 3.2.7
Linux Kernel 4.9.0-8-amd64
Installed packages: https://pastebin.com/DeYAvJtu
Many thanks to the user dugan on linuxquestions.org! He solved my problem here.
I just had to install Qt from a different source (I used the Qt installer, as mentioned in the question), to have a different version of it in another location. The reason for that is that many programs on Debian rely on an earlier version of Qt, so just updating it would break a lot, that's also why Synaptic&Co. don't update it.
Then I had to add the binary to the PATH variable, like so:
export PATH=/home/fabian/Qt/5.11.2/gcc_64/bin:$PATH
Then I was able to just install Dolphin beta regularly, like the tutorial says it.

Compiling and Linking against plplot library on debian

I am using Code::Blocks IDE on Debian 8. I have installed the plplot library form synaptic (not from source). When I create new project in C::B and try to run a simple plplot example the compiler do not recognize the includes and the linker do not recognize the plplot library. So how to compile and link with plplot library when I have installed it from Synaptic not from source? Is this possible, or I should remove current packages and install from source only?
In general when I install new library (from synaptic or from source) how to find out what should be the compiler flags and search directories and for the linker too? I think installing from source should be the less problems prone way!
Till now I am doing file search for the included header and add its directory to the search path for the compiler. But this is very cumbersome and naive approach. It will be better if I add compiler flag that does all this job, but how to find it out. Some flags I find in forums but not in the documentation of the libraries. Why there is no file with the third program library to tell what flags should one use? Nevertheless when the o files are done I have linker errors like "undefined reference to...".
For the plplot library the linker flag should be -lplplotd. For the compiler options I have no flags but I did a search for the unknown headers and added their directories to the search directories path. Now the Example 00 works fine. Though I found the -lplplotd flag by shooting! For the x11 examples one should add the flag -lplplotcxxd.
In general I got that to find the linker flag I have to search for the library so file and the name of the file commonly is the flag, e.g. for the library libplplotcxxd.so the flag is -lplplotcxxd.
Anyway, I'd be glad if someone tells me a better clue on finding these linker flags.

Cant use shared libraries in Qt project

I created a C++ library project in Qt creator. After building the project I have the libMylib.so, .so.1, .so.1.0, .so.1.0.0, Makefile and mylib.o files. I added the library headers to my other project and added the path to my .pro file like this:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
When building the application I don't get no such file error, but when running it I get this:
/home/peter/Workspace/build-Libtester-Desktop-Debug/Libtester: error while loading shared libraries: libMyLib.so.1: cannot open shared object file: No such file or directory
which I can't understand, because it's right there next to the .so which it seem to find, because when the path is wrong I get a no such file or directory error when trying to build the project.
Could someone explain what I'm missing here?
Thanks for your time.
Fortunately, your problem has nothing to do with both Qt and Qt Creator. The error simply boils down to how shared libraries are searched by LD for dynamic linking on Unix OS family.
Today, I've answered similar question, have a look, please. This question was asked in regard to Mac OS X. However, Linux and Mac OS X are the same in the context of your problem. I've provided additional explanation for Linux at the bottom, so pay attention to it. "it's right there next to the .so" - you seem to have Windows background if you make this assumption, but it is wrong for Unix OS family altogether (as stated in the answer too). If you have further questions, just ask.
You are adding the library incorrectly. You are doing:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
instead of:
LIBS += -L"/home/peter/Workspace/build-Libtester-Desktop-Release" -lMyLib
The first version works on windows, but not linux.
Basically, you create a library, which will be named "libMyLib.so", and then you specify the path to its folder, prepended by "-L" and then do "-lMyLib" at the end, note that it's not "-llibMyLib", but just "-lMyLib", despite the fact that the .so name is "libMyLib".
Look here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application for more info.

qt png in resource corrupted after static linking

We're developing a quite large Qt-based project on linux, and we reached final RC1 stage.
Now, we encountered something really strange: in order to go into production, we added another .a library in our list of static linking libs.
The library is linked and the application runs, but every .png in the resource file is corrupted, here's the output on startup:
libpng error: IHDR: CRC error
seems like libpng cant handle those invalid png (of course). The files are there and the size is right, they just turned blank after static linking that final library. The library itself is not used anywhere, it is just linked.
Has anyone encountered such a situation before? is there a known workaround? We're using Qt 4.7.4 x64 on QtCreator 2.3.0, we would like not to upgrade for now, but it is the only option that comes into our mind for now.
It could fit a problem with symbols.
The static library and libpng could be at same time linking to other library and when linking or resolving in compile/load time something weird is happening.
You can use objdump command to inspect symbols (objdump -tT /usr/bin)
Have you tried modifying the library order when compiling/linking? I mean, for example,
gcc -lmylibrary -lQt -lOtherLOLibrary
instead of
gcc -lOtherLOLibrary -lQt -lmylibrary
And I think I'm missing something, why do you link against an unused library?

Resources