I am a mac user running 10.10.5 Yosemite and Xcode 6.3.2. In Documents there is a folder (generated by a command line tool project written in C++) called 'Game' with this structure:
Game:
Game.xcodeproj (my project)
Game:
main.cpp (my c++ source)
Build:
Products:
Debug:
Game (an executable)
SDL2.framework (a development library)
I want to link to the SDL2.framework in Build/Products/Debug in such a way that it will run on any Mac, from this specific folder.
I have performed these steps:
I dragged SDL2.framework from Build/Products/Debug into my Project Navigator. I unchecked 'copy if needed.'
This automatically added the 'Link Binary with Libraries' build phase in which SDL2.framework is included.
SDL2.framework is referenced relative to group- in 'Build/Products/Debug/SDL2.framework,' as desired.
In my main.cpp I write:
# include "SDL2/SDL.h"
The generated executable runs on my machine no matter where the 'Game' folder highest in the hierarchy is.
My project is not referencing the SDL2.framework in /Library/Frameworks. I can change the name of the SDL2.framework there and the program still runs. This suggests it is taking it from /Build/Products/Debug as I want it to.
However, when I take this whole folder onto a mac identical to mine the executable runs, but fails with this error:
Last login: Sat Mar 26 11:32:08 on ttys002
[~/ 1> /Volumes/NO\ NAME/Game/Build/Products/Debug/Game ; exit;
dyld: Library not loaded: #rpath/SDL2.framework/Versions/A/SDL2
Referenced from: /Volumes/NO NAME/Game/Build/Products/Debug/Game
Reason: image not found
Trace/BPT trap
logout
[Process completed]
Having spent hours searching for a solution, I am dumbfounded. What am I doing wrong?
Related
So i am new on the platform, i use c/c++ and i have interests in graph interfaces so i decided to use gtk+and gtkmm with visual studio.
First, i downloaded gtk for the gnome project. I followed all the steps and i got this after a manual run :
\\\ test23.cpp
#include <gtkmm.h>
int main(int argc, char* argv[])
{
Gtk::Main app(argc, argv);
Gtk::Window fenetre;
Gtk::Main::run(fenetre);
return 0;
}
$ g++ -std=c++ test23.cpp $(pkg-config gtkmm-3.0 --cflags --libs | sed 's/ -I/ -isystem /g')
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
bash: g++: command not found
so i decided to install using vcpkg.
But I failed to install gtk+ and gtkmm after multiple tries.
Here what i've got :
C:\WINDOWS\system32>vcpkg install gtk
Computing installation plan...
The following packages will be built and installed:
gtk[core]:x86-windows
* harfbuzz[core,glib]:x86-windows
* libepoxy[core]:x86-windows
* pango[core]:x86-windows
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x86-windows...
Starting package 1/4: libepoxy:x86-windows
Building package libepoxy[core]:x86-windows...
Could not locate cached archive: C:\Users\Manolo97233\AppData\Local\vcpkg\archives\f7\f743ec00b235ca7fd37812284b7d2e09d89b368a.zip
-- Using cached C:/Windows/SysWOW64/vcpkg/downloads/anholt-libepoxy-1.5.4.tar.gz
-- Cleaning sources at C:/Windows/SysWOW64/vcpkg/buildtrees/libepoxy/src/1.5.4-337c486045.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source C:/Windows/SysWOW64/vcpkg/downloads/anholt-libepoxy-1.5.4.tar.gz
-- Applying patch libepoxy-1.5.4_Add_call_convention_to_mock_function.patch
-- Using source at C:/Windows/SysWOW64/vcpkg/buildtrees/libepoxy/src/1.5.4-337c486045.clean
-- Acquiring MSYS Packages...
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:72 (message):
Command failed: C:/Windows/SysWOW64/vcpkg/downloads/tools/msys2/msys64/usr/bin/bash.exe --noprofile --norc -c "pacman -S --noconfirm --needed pkg-config"
Working Directory: C:/Windows/SysWOW64/vcpkg/downloads/tools/msys2
Error code: 1
See logs for more information:
C:\Windows\SysWOW64\vcpkg\buildtrees\libepoxy\msys-pacman-x86-windows-err.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_acquire_msys.cmake:127 (vcpkg_execute_required_process)
scripts/cmake/vcpkg_configure_meson.cmake:106 (vcpkg_acquire_msys)
ports/libepoxy/portfile.cmake:16 (vcpkg_configure_meson)
scripts/ports.cmake:79 (include)
I believed i had a problem with msys2 so i tried to install it separately following an install kit unsuccessfully.
then i tried to run separately other packages involved with gtkmm like pango and i got this :
//vcpkg install pango
Computing installation plan...
error writing file: C:\Windows\SysWOW64\vcpkg\buildtrees\0.vcpkg_dep_info.cmake: The data is invalid.
Someone explained on a topic it could be an vcpkg accessibility problem for others packages. i modified the accessibility of vcpkg for other packages in my systWOW64'file parameters but it went unsuccessful.
I don't know if vcpkg is problem because i did not remove it and re install it.
I am looking for solutions/options, I am short on ideas, i literally need some help.
Thanks
Use JHbuild, its your friend when building GNOME applications from source !
Run jhbuild build gtkmm --nodeps, the built files will be installed in $HOME/jhbuild/build. To compile your application with it, you must export the environment variable PKG_CONFIG_PATH as follows:
export PKG_CONFIG_PATH="$HOME/jhbuild/build/lib/pkgconfig"
(in the terminal you are running the g++ command from)
And you have to install g++.
I do not know how you are using bash together with visual studio, but
if you have apt, you can install g++ and gtkmm with the following command :
apt install libgtkmm-3.0-dev libgstreamermm-1.0-dev g++
If you have already downloaded gtk, then the downloaded package must contain a .pc file. The directory this file is in when you installed the downloaded package you must add to the PKG_CONFIG_PATH.
Thanks Frederic for your answer it really help me.
I have got an other question. In my quest to add external packages to my C/C++ project, i read differents topics about how to convert static library (.a) into static library (.lib).
I downloaded packages and i wanted to add them manually using their pathway.
I added my packages as followed:
1 / Add the path of the headers in the compiler directories for the project:
-> Project / Properties menu
-> On the left tree, choose Configuration properties - C / C ++ - General
-> On the right table, the first line "Other Include directories": add the directory (s) of your library containing the headers
2 / Add the path of the .lib in the compiler directories for the project:
-> Project / Properties menu
-> On the left tree, choose Configuration Properties - Link Editor - General
-> On the right table, the line "Directory of additional libraries": add the directory (s) of your library containing the .libs
3 / Specify the libraries with which your project is linked:
-> Project / Properties menu
-> On the left tree, choose Configuration Properties - Link Editor - Enter
-> On the right table, the first line "Additional dependencies": add the .lib library (s) with which your project must be linked
But I looked for .lib files to add to my linker input instead, I found .a files and .dll files and I didn't know what to do. . a files and .lib files are almost identical. It seems like .a files are used under linux while .lib are used under windows.
I tried to add the .a files unsuccesfilly. I wondered if I could convert an .a file into a .lib file.
Thanks
For a while now, I have been trying to use the SFML library for C++.
However, whenever I try to run my program, I get a slew of build errors revolving around undefined symbols. I am building from Visual Studio and I have added the include directory, the additional libraries, and the all the DLLs in bin into BOTH the source directory and the build directory. Still, I cannot get the program to build.
My Code:
#include <SFML\Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 380), "Test Window");
while (window.isOpen()) {
// events
window.clear();
// drawing
}
system("pause");
}
Errors:
Include Directories: SFML-2.4.2/include
Lib Directories: SFML-2.4.2/lib
Linker Input:
sfml-main-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-audio-d.lib
sfml-network-d.lib
I know this is like one and a half year old but I had the same errors and I have resolved them.
The following Pastebin files are my config and task files which(in my case work fine with Visual Studio Code Version 1.32.3 read the bottom for what you will have to change)
Date:2019-03-14
Electron:3.1.6
Chrome:66.0.3359.181
Node.js:10.2.0
V8:6.6.345.32
Os: Windows_NT x64 10.0.17134
c_cpp_properties.json: https://pastebin.com/3gw8J4d2``
task.json: https://pastebin.com/s1rjswWG``
IMPORTANT:
change the following:
(If you have MinGW installed on the standard path)
c_cpp_properties.json: K:/libs/SFML-2.5.1/include has to be changed
to your installation path of SFML be sure to change it in the browse path too!!!
tasks.json:
"-IK:/libs/SFML-2.5.1/", change K:/libs/SFML-2.5.1/include to your
installation path of SFML
"-LK:/libs/SFML-2.5.1/lib", change K:/libs/SFML-2.5.1/lib again to
your installation path of SFML
a few mistakes I made:
I didn't delete the K: in "-LK:/libs/SFML-2.5.1/lib"
I didn't have g++ in command at the top of tasks.json
I didn't use the right compiling/link paths (search for all paths you
use in your browser before giving up)
A few helpful Links:
https://www.sfml-dev.org/download/sfml/2.5.1/ (for MinGW be sure to
select GCC 7.3.0 MinGW (DW2) - 32-bit)
https://code.visualstudio.com/docs/languages/cpp (Documentation on
how to compile in Vs with c++)
https://discordapp.com/invite/nr4X7Fh (Discord Server of SFML where
are a lot of helpful people for the library)
I hope I helped
If you have any question you can message me on Reddit u/Spagetti_Lord (most active)
last week I recieved my brand new Colibri VF61 with the Aster carrier board from Toradex.
I followed Toradex's guide on how to prepare the board to cross compile with qt here.
Everything from the tuturial went perfect, however I tried deploying my app and everything goes fine until I open the executable on my target device because I get the following message :
error while loading shared libraries: libQt5PrintSupport.so.5: cannot open shared object file: No such file or directory
I went to see if I had any Qt files in my target device at all, and there weren't so I went to my sysroot folder in my host device and I copied all the Qt files to my target device, (Qt5PrintSupport was there) but after I copied all the files in the exact same location as they where in my sysroot the same error keep appearing.
The files I copied were:
LibIcal Qt5Core Qt5OpenGLExtensions Qt5Svg
PulseAudio Qt5DBus Qt5Positioning Qt5SystemInfo
Qt5 Qt5Declarative Qt5PrintSupport Qt5Test
Qt53DCore Qt5Designer Qt5PublishSubscribe Qt5UiPlugin
Qt53DExtras Qt5Enginio Qt5Qml Qt5UiTools
Qt53DInput Qt5Gui Qt5Quick Qt5WebChannel
Qt53DLogic Qt5Help Qt5QuickTest Qt5WebKit
Qt53DQuick Qt5LinguistTools Qt5QuickWidgets Qt5WebKitWidgets
Qt53DQuickExtras Qt5Location Qt5Script Qt5WebSockets
Qt53DQuickInput Qt5Multimedia Qt5ScriptTools Qt5Widgets
Qt53DQuickRender Qt5MultimediaWidgets Qt5Sensors Qt5X11Extras
Qt53DRender Qt5Network Qt5SerialPort Qt5Xml
Qt5Bluetooth Qt5Nfc Qt5ServiceFramework Qt5XmlPatterns
Qt5Concurrent Qt5OpenGL Qt5Sql libxml2
Inside /usr/lib/cmake
and:
imports libexec mkspecs plugins qml
folders to /usr/lib/qt5
I have noticed that the problem may be that I dont have the "lib" folder inside /usr/lib/qt5 however I don't know how to create it since it wasn't in my sysroot.
Summing up: I want to execute my app by cross compiling but the lib folder is missing and I don't know how to create it or link it.
Having a library in the same path with the app using it doesn't necessarily mean that your app can find it. Follow one of the methods below;
Install the required qt libraries into system's standard lib directory(e.g. /usr/lib/)
Set environment variable LD_LIBRARY_PATH to where your qt libraries exist. Convention is generally having a bash script setting it then launching your app) or
At compile time, you set rpath variable to the location of qt libraries folder (-rpath for gcc)
I am getting the following issue:
/Users/luke/Desktop/trainHOG/trainhog ; exit;
dyld: Library not loaded: lib/libopencv_core.3.0.dylib
Referenced from: /Users/luke/Desktop/trainHOG/trainhog
Reason: image not found
Trace/BPT trap: 5
logout
I am using a Mac running OSX v10.9.5 with openCV 3.0 alpha.
The library in question is definitely in the folder. I have tried deleting it and pasting it back into the folder, I have completely deleted and reinstalled openCV and macports, and I have tried the export DYLD_LIBRARY_PATH = "path to dynamic libs here..", but nothing has worked. I have even rebooted my computer on several occasions!
Does anyone have any further suggestions? I am out of ideas
OpenCV 3.3
OSX 10.13
fist have a test, you can use clang++ -o a -I ./include -L ./lib
-lopencv_core.your.version
then you can generate executable file a ,run it ,if have the error massage.
you will find the error reason cannot find the lib when you are link.
if you want to solve error on terminal
you can use export DYLD_LIBRARY_PATH=your/lib:$DYLD_LIBRARY_PATH
if you want to solve error on Xcode
in build page , go to "Runpath Search Paths"
add you lib path
If you use
export DYLD_LIBRARY_PATH = "path to dynamic libs here.."
is it applied to the environment of your program?
You can check the environment variables of a running process with
ps -p <pid> -wwwE
Does this help?
If you are having this Problem:
dyld: Library not loaded: *.dylib ... Reason: no suitable image found.
Means your *.dylib files are not signed with your Apple iD develop account, and
There is two ways to solve that:
1) The right way: Code sign all your files with errors with this command:
codesign -f -s "Mac Developer: YOURDEVELOPEREMAIL" /usr/local/opt/*/lib/*.dylib
2) The temporary way(until you don't deploy to App Store): Inside Xcode, go to:
[YourProjectFile] --> [YourTargetFile] --> "Signing & Capabilities" --> and Enable "Disable Library Validation"
Done :D
Seems to be a bug in some versions of OpenCV's CMake configuration files which incorrectly record relative paths in the installed dylibs, reasonably easy to fix.
This answer on answers.opencv.org addresses the issue. In OpenCVModule.cmake and every instance of CMakeLists.txt replace INSTALL_NAME_DIR lib with INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib.
I am trying to add the liboauth.dylib to my xcode project (c++). I have configured and made the library, which is now sitting in my /usr/local/lib which now has:
liboauth.0.dylib
liboauth.dylib <- a link to liboauth.0.dylib
liboauth.li
liboauth.a
with the header in usr/local/include. Seems fine.
I have included this in my xcode by adding the path /usr/local/lib/liboauth.dylib to the Other Linker Flags section, and usr/local/include/ to the Header Search Paths.
I have also included the same in the Library Search Paths.
This builds fine on my system. However if I take the resulting .app to another (osx) computer it gives the error the /usr/local/liboauth.0.dylib (I get this by opening the .app and running the unix executable).
Shouldn't the linker have included the liboauth dylib when built? And then it shouldn't be a problem when going to a different computer?
If the answer is no, then how would I go about included the liboauth.dylib into the .app, so it can run on any computer (running osx)?
Here is the specific error:
Library not loaded: /usr/local/lib/liboauth.0.dylib
Referenced from: /Users/scratch/gameTest.app/Contents/MacOS/gameTest
Reason: image not found
Edit: I have found the problem! Using the otool -l command on the liboauth.0.dylib I found this:
Load command 3
cmd LC_ID_DYLIB
cmdsize 56
name /usr/local/lib/liboauth.0.dylib (offset 24)
time stamp 1 Thu Jan 1 12:00:01 1970
current version 9.1.0
compatibility version 9.0.0
Can someone help me to figure out how to change this? I think it has something to do with the install_name_tool but I do not know how to go about it properly.
Are both system the same? 32-bit/64-bit, Snow Leopard vs. Leopard.
I can see how the libraries would be different and that error could be produced if that was the case.
If they are the same, it is possible that you are setting the linker flags in your project settings and it is being overridden by your target settings.