Xcode gives error when I add libraries: dyld: Library not loaded - c++

First I wanted to learn SDL in xcode, but when I try to add SDL framework this error pops up and I can't understand why. I looked on the internet for 2 days but couldn't find any solution. After 1 month (now) I'm trying to add GLFW to xcode but this error got me again. Why is this error happening?
dyld: Library not loaded: /usr/local/opt/glfw/lib/libglfw.3.dylib
Referenced from: /Users/durdukolk/Library/Developer/Xcode/DerivedData/Graphic-dutmtfjytmmfetggltqeajfkggms/Build/Products/Debug/Graphic
Reason: no suitable image found. Did find:
/usr/local/opt/glfw/lib/libglfw.3.dylib: code signature in (/usr/local/opt/glfw/lib/libglfw.3.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
/usr/local/Cellar/glfw/3.3.4/lib/libglfw.3.3.dylib: code signature in (/usr/local/Cellar/glfw/3.3.4/lib/libglfw.3.3.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

I finally found the solution.First you need to open "Enable hardened runtime" in section Signing in the project file.
And need the check "Disable Library Validation" at product menu.
For more detail: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_disable-library-validation

Related

SMFL library not loaded error in Mac OS BigSur

Hello I have installed SFML in my M1 chip Bigsur using this tutorial https://www.youtube.com/watch?v=WOyp5n2FmZY and also fixed all the error related to M1 chip.But when I run my project I get this pop ups.
popups
dyld: Library not loaded: #rpath/../Frameworks/vorbisfile.framework/Versions/A/vorbisfile
Referenced from: /Library/Frameworks/sfml-audio.framework/Versions/2.5.1/sfml-audio
Reason: no suitable image found. Did find:
/Library/Frameworks/vorbisfile.framework/Versions/A/vorbisfile: code signature in (/Library/Frameworks/vorbisfile.framework/Versions/A/vorbisfile) not valid for use in process using Library Validation: library load disallowed by system policy
It even showed pop ups for every frameworks I went to settings and gave allow for each of them. But it kept on showing same popup how can I solve this problem in BigSur
I think you will find that the library in question has been quarantined by the operating system. I would suggest:
confirm the quarantine flag ls -l# /path/to/library-or-library_bundle
remove the quarantine flag sudo xattr -d com.apple.quarantine /path/to/library-or-library_bundle
You can also go to your system preferences, then Security & Privacy. On General you see the settings for Allow apps downloaded from:. If you have a message like the one you have mentioned above, it says here "your.framework" was blocked from use because it is not from an identified developer with a button Allow Anyway next to it. Click it.

Get reason that LoadLibrary cannot load DLL

On Linux and Mac, when using dlopen() to load a shared library that links to another library, if linking fails because of a missing symbol, you can get the name of the missing symbol with dlerror(). It says something like
dlopen failed: cannot locate symbol "foo"
On Windows, when using LoadLibrary() to load a DLL with a missing symbol, you can only get an error code from GetLastError() which for this type of issue will always be 127. How can I figure out which symbol is missing, or a more verbose error message from LoadLibrary() that explains why the function failed?
I figured out a way using the MSYS2 terminal. Other methods might work with GUI software.
A major caveat is that this can't be done in pure C/C++ and released for end users. It's for developers only, but it's better than nothing.
Install Debugging Tools for Windows by downloading the Windows SDK and unchecking everything except Debugging Tools.
I could be wrong, but it seems that installing this software installs a hook into the Windows kernel to allow LoadLibrary() to write verbose information to stderr.
Open the MSYS2 Mingw64 terminal as an administrator and run
'/c/Program Files (x86)/Windows Kits/10/Debuggers/x64/gflags.exe' -i main.exe +sls
This prints the following to the terminal to confirm that the registry has been changed.
Current Registry Settings for main.exe executable are: 00000002
sls - Show Loader Snaps
Use -sls instead of +sls if you need to undo, since I believe that the change takes place for all programs called main.exe in Windows globally, not just for your file.
Then running main.exe should print debug information to stderr, but since I'm debugging an -mwindows application, it's not working for me.
But for some reason, running the binary with MSYS2's gdb allows this debug information to be printed to stderr.
Install mingw-w64-x86_64-gdb with MSYS2 and run gdb ./main.exe and type run or r.
Search for a section similar to the following.
warning: 1ec8:43a0 # 764081125 - LdrpNameToOrdinal - WARNING: Procedure "foo" could not be located in DLL at base 0x000000006FC40000.
warning: 1ec8:43a0 # 764081125 - LdrpReportError - ERROR: Locating export "foo" for DLL "C:\whatever\plugin.dll" failed with status: 0xc0000139.
warning: 1ec8:43a0 # 764081125 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapModule raised exception 0xc0000139
Exception record: .exr 00000000050BE5F0
Context record: .cxr 00000000050BE100
warning: 1ec8:43a0 # 764081125 - LdrpProcessWork - ERROR: Unable to load DLL: "C:\whatever\plugin.dll", Parent Module: "(null)", Status: 0xc0000139
warning: 1ec8:43a0 # 764081171 - LdrpLoadDllInternal - RETURN: Status: 0xc0000139
warning: 1ec8:43a0 # 764081171 - LdrLoadDll - RETURN: Status: 0xc0000139
Great! It says Procedure "foo" could not be located in DLL so we have our missing symbol, just like in POSIX/UNIX's dlopen().
While the answer from Remy Lebeau is technically correct, determining the missing symbol from GetLastError() is still possible on a Windows platform. To understand what exactly is missing, understanding the terminology is critical.
Symbol:
When a DLL is compiled, it's functions are referenced by symbols.
These symbols directly relate to the functions name (the symbols are
represented by visible and readable strings), its return type, and
it's parameters. The symbols can actually be read directly through a
text editor although difficult to find in large DLLs.DLL Symbols - C++ Forum
To have a missing symbol implies that a function within cannot be found. If this error occurs prior to using GetProcAddress(), then it's possible that any number of functions cannot be loaded due to missing prerequisites. This means it is possible that a library that you are attempting to load also requires a library that the first cannot load. These levels of dependency may go on for an unknown number of layers, but the only answer that GetLastError() can determine is that there was a missing symbol. One such method is by using Dependency Walker to determine the missing library the first library requires. Once all required libraries are available and can be found by that library (which can be its own can of worms), that library can be loaded via LoadLibrary().

Kylin odbc driver C++ solution fails to build

I am unable to build Kylin ODBC C++ solution.
I followed the instructions found here, unfortunately, I get an error when I try to build the solution.
I am getting the below error message:
Error LNK1181 cannot open input file
'zlibstat.lib' Common C:\Users\user1\Documents\Visual Studio
2015\Projects\kylin-master\odbc\Common\LINK 1
When I include the zlibstat.lib file, I get an error message saying that it is already included.
The Error looks like your zlibstat.lib cannot be found.
Please check whether ZLIB_HOME is set in Environment Variables and whether project zlib is well compiled.
You can verify with check in file Common.vcxproj .
For example you want to build with Release|x64, please check whether can find zlibstat.lib in location $(ZLIB_HOME)\contrib\vstudio\vc11\x64\ZlibStatRelease.

QT Quick (QML) assemble mac-.bundle -> not a dynamic library error when using macdeployqt

I struggle with this for weeks now and hope someone finds this useful or knows an answer.
- I use QT 5.7 and QT 5.8 and the error occurs on both versions.
I have a QT Quick 2.0 application which I build as a dynamically linked .bundle application on a Mac using macdeployqt.
I call macdeployqt with the following parameters:
%{buildDir}/imageDatabase.app -qmldir=%{buildDir}/../UserInterface/ -always-overwrite -verbose=2
The working directory is $QTDIR/bin because macdeploy needs to be run from inside the QT-Installation directory as I learned here: https://forum.qt.io/topic/59030/solved-macdeployqt-problem/6
The following error occurs when I try to run the application:
Double-click: The app opens and the icon appears in the bar on the bottom but besides that nothing happens
Starting the app from Terminal:
Output
Machine:MacOS MyName$ ./tool
QQmlApplicationEngine failed to load component qrc:/main.qml:1 plugin cannot be
loaded for module "QtQuick": '/Users/thorstenbux/DAQRI/gitHub/artoolkit6/Source/Utilities/ImageDBSerialiser/build-ui/imageDatabase.app/Contents/PlugIns/quick/libqtquick2plugin.dylib'
is not a valid Mach-O binary (not a dynamic library)
Calling file on the library in question reveals the following
Machine:MacOS MyName$ file /Users/myname/client/gitHub/tool/SDK/Applications/tool.app/Contents/PlugIns/quick/libqtquickcontrolsplugin.dylib
/Users/myname/client/gitHub/tool/SDK/Applications/tool.app/Contents/PlugIns/quick/libqtquickcontrolsplugin.dylib: Mach-O 64-bit dSYM companion file x86_64
looks like it is loading the debug libraries.
macdeployqt error message is the following:
ERROR: Could not parse otool output: "/Users/myname/DAQRI/gitHub/tool/Source/Utilities/tool/build-tool-Desktop_Qt_5_8_0_clang_64bit-Release/tool.app/Contents/PlugIns/quick/libqtquick2plugin.dylib:\n"
Any ideas?
I finally found a solution in the QT forums. It looks like the macdeployqt has a severe bug: https://bugreports.qt.io/browse/QTBUG-57265
You need to call macdeployqt without the -always-overwrite option.
Many thanks to Andy Shaw who posted that here:
https://bugreports.qt.io/browse/QTBUG-57265?focusedCommentId=346168&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-346168

Netbeans IDE 8.0.2 C++ Input/Output Error

I installed netbeans C++ on windows 7 and used Cywgin4 as the compiler. When I run any program even a simple Hello world it does compile and run however I also get the error below. I can't seem to find any reference to it online. Can anyone point me in the right direction for a solution? Thanks!
read from master failed
: Input/output error
RUN FAILED (exit value 1, total time: 47ms)
I do not understand all the surrounding details of this problem as I am new to C/C++. However, if you:
Open up NetBeans
Right click on your C++ project file
Select "Properties"
There should be a category called "Run".
Under this category, find the option called Console Type and make sure that Standard Output is selected as shown in the screenshot below:
I was having the same problems when the console type was selected as Internal Terminal.
For my setup, changing this option to Standard Output got rid of this error. However, I do not fully understand how this change affects the overall properties of my project. Wish you good luck.