Building OsiriX on Mac OS X Lion - build

Ld build/Development/Decompress normal i386
cd /Users/icthealth/Desktop/dcmtk/osirix/osirix
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -L/Users/icthealth/Desktop/dcmtk/osirix/osirix/build/Development -LBinaries/LibTiff -L/Users/icthealth/Desktop/dcmtk/osirix/osirix/Binaries -L/Users/icthealth/Desktop/dcmtk/osirix/osirix/Binaries/Ming "-L/Users/icthealth/Desktop/dcmtk/osirix/osirix/Binaries/KDU SDK" -L/Users/icthealth/Desktop/dcmtk/osirix/osirix/Binaries/CharLS -L/Users/icthealth/Desktop/dcmtk/osirix/osirix/Binaries/VTKLibs -F/Users/icthealth/Desktop/dcmtk/osirix/osirix/build/Development -F/Users/icthealth/Desktop/dcmtk/osirix/osirix -filelist /Users/icthealth/Desktop/dcmtk/osirix/osirix/build/OsiriX_Lion.build/Development/Decompress.build/Objects-normal/i386/Decompress.LinkFileList -mmacosx-version-min=10.7 -framework Foundation -framework AppKit -framework Foundation -framework Cocoa -framework QuickTime -framework IOKit -lz "-lDCM StaticLibrary" -framework Accelerate -framework QTKit -framework WebKit -lPapyrusToolkit -lfreetypeOsiriX -lgifOsiriX -lmingOsiriX -lpng12OsiriX -lkdu_v64R -framework Quartz -lCharLS -lvtkzlib -o /Users/icthealth/Desktop/dcmtk/osirix/osirix/build/Development/Decompress
Undefined symbols for architecture i386:
".objc_class_name_DCMPix", referenced from:
pointer-to-literal-objc-class-name in Decompress.o
(maybe you meant: .objc_class_name_DCMPixelDataAttribute)
"_PapyrusLockFunction", referenced from:
_ExtractJPEG2000 in libPapyrusToolkit.a(PapyRead3.o)
_ExtractJPEGLS in libPapyrusToolkit.a(PapyRead3.o)
_ExtractJPEGlossy16 in libPapyrusToolkit.a(PapyJpeg16.o)
_ExtractJPEGlossy12 in libPapyrusToolkit.a(PapyJpeg12.o)
_ExtractJPEGlossy8 in libPapyrusToolkit.a(PapyJpeg8.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
While building after creating the Development Scheme for Mac OS X Lion 10.7, the above build errors are generated. Any clues how I can compile OsiriX on Mac OS X Lion 10.7?

Although this answer doesn't seem conclusive, I would like to mention what worked and what didn't. Before that, I am using Xcode version 4.3.2 and Mac OS X Lion 10.7.4. I downloaded the source code zip file for OsiriX.
Select "Unzip Binaries" and My Mac 32-bit as the target scheme first, and build and run. (This one was always successful).
Select "Osirix" and My Mac 32-bit as the next target scheme and, in this version of Xcode it says "Validate Project Settings", as it seemed to be necessary to update the compiler from llvmgcc42 to Apple LLVM, and change the Base SDK to latest Mac OS X (10.7) from the current 10.6 version.
When this change was performed, it threw up varieties of build errors, like the one on my original question, and Apple Mach-O linker error, CLang error, exited with code 1. and so on.
The successful compilation of Osirix in my opinion depends on keeping the old compiler and not updating to latest project settings.

Related

OpenGL Link Error for GLFW DDS Load function

I have been working my way through the OpenGL-tutorial.org tutorial series. All has been working fine, however I have not been able to get Tutorial 5 to work in my playground executable, though it does work when run from the example tutorial 5 executable. This is true even when I copy and paste the example code over.
I receive the following errors:
Undefined symbols for architecture x86_64:
"loadDDS(char const*)", referenced from:
_main in playground.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Below is the link log:
Ld playground/playground normal x86_64
cd /Users/RufusVijayaratnam/rufus/Coding/ogl-master
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -F/Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground -filelist /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_lto.o -Xlinker -no_deduplicate -Wl,-search_paths_first -Wl,-headerpad_max_install_names -framework OpenGL -framework OpenGL /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/glfw-3.1.2/src/Debug/libglfw3.a /Users/RufusVijayaratnam/rufus/Coding/OpenGL/external/Debug/libGLEW_1130.a -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo -Xlinker -dependency_info -Xlinker /Users/RufusVijayaratnam/rufus/Coding/OpenGL/Tutorials.build/Debug/playground.build/Objects-normal/x86_64/playground_dependency_info.dat -o /Users/RufusVijayaratnam/rufus/Coding/ogl-master/playground/playground
So the error appears to be that when the function loadDDS() is called that it is not found. I am unsure as to why this is. The function is declared in texture.ccp which is in a folder (called 'common'), along with texture.hpp. texture.hpp has the code below:
#ifndef TEXTURE_HPP
#define TEXTURE_HPP
// Load a .DDS file using GLFW's own loader
GLuint loadDDS(const char * imagepath);
#endif
In playground.cpp there is:
include<texture.hpp>
Why can't loadDDS() be found, even though I have set the working directory of the playground function to the same as that for Tutorial 5, and the code in playground.ccp and 'tutorial05.ccp' is exactly the same?
for the playground executable (doesn't work)
# User playground add_executable(playground
playground/playground.cpp
common/shader.cpp
common/shader.hpp )
and finally for tutorial 5 (does work)
# Tutorial 5
add_executable(tutorial05_textured_cube
tutorial05_textured_cube/tutorial05.cpp
common/shader.cpp
common/shader.hpp
common/texture.cpp
common/texture.hpp
So I'm making the educated guess that loadDDS() is implemented in texture.cpp, and since you did not add this file, it won't be compiled, and the resulting object file won't be linked, and the symbol will just not be found.

GCC 5.4 linker error after upgrading to Xcode 8

Recently I updated to XCode Version 8.0 (8A218a) on El Capitan (OS X 10.11 using Macports 2.3.4), and ever since, I have been getting the following link error when I try to compile my project inside Qt Creator.
/opt/local/bin/g++-mp-5 -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.8 -Wl,-rpath,/Users/zero/builds/Qt5.7.0/5.7/clang_64/lib -o uniMR.app/Contents/MacOS/uniMR ALL_OBJECT_FILES_GO_HERE.o -F/Users/zero/builds/Qt5.7.0/5.7/clang_64/lib -L/opt/local/lib -L/usr/local/lib -funit-at-a-time -fopenmp -lmlpack -larmadillo -framework CoreFoundation -DNDEBUG -lpthread -lALL_ITK_LIBS_GO_HERE -framework QtOpenGL -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework QtXml -framework OpenGL -framework AGL
**ld: unexpected token: !tapi-tbd-v2 file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [uniMR.app/Contents/MacOS/uniMR] Error 1**
I am compiling the main project with gcc 5.4 (not clang) inside QtCreator (Qt 5.7), and all my dependent libraries (ITK, BOOST, etc) are compiled using gcc 5.4 as well. I also recompiled all my dependent libraries after upgrading XCode, but that did not help either. I could find only one post that is related to the error I am seeing, but it doesnt seem useful:
https://trac.macports.org/ticket/51701
All was fine before I upgraded XCode. Now I am not sure how to fix the issue. I would appreciate any help on this. Thanks.
UPDATE:
This doesnt seem like a problem with any of the external libraries I am linking with. This is what I did. I created a new "QT widgets application" in QtCreator, and chose to compile with gcc5. I get the same error ld: unexpected token: !tapi-tbd-v2. If I switch to clang, then there is no error.
I had this "ld: unexpected token: !tapi-tbd-v2" error building an unrelated project and was able to solve it by editing the .tbd file for the framework that was giving the error.
For me that file was:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate.tbd
I simply removed the entire line "--- !tapi-tbd-v2" while building, and then put it back once finished.
had yesterday the same problem. I had XCode 7.3 and 8 on my system. Removing 7.3 and moving 8 into the apps location solved the problem.
I had the same problem. I used macport's GCC 6 as compiler and linker. It seems the GCC doesn't understand the new tbd format. In the MacOSX SDK path, there are now only these tbd text files which contain info about the real dylib libraries. So I just symlinked the real libraries to the SDK paths beside their tbd files. Then GCC can directly use the real libraries without parsing tbd files.
Here is a script for creating those symlinks:
https://gist.github.com/michalfapso/9abdbd5669bfdc4cd1a2179824d299e9
I had the same problem while compiling with opam.
The workaround was PATH=/usr/bin:$PATH, thus gcc will resolve to the default /usr/bin/gcc which is clang on macOS.

Linker error with GLFW on OS 10.10

I'm trying to compile the following
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
return 0;
}
just to verify that my GLFW installation is working. I use the terminal with
clang++ -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -I/opt/local/include/ test.c
but I receive a linker error for the glfwInit function:
Undefined symbols for architecture x86_64:
"_glfwInit", referenced from:
_main in test-d8c21e.o
ld: symbol(s) not found for architecture x86_64
I have installed glfw with sudo port install glfw and followed every possible tutorial I've found. I can verify that the libglfw.dylib file can be found at /opt/local/lib/ as (I think) it should.
Any suggestions?
You need to link with GLFW[3] as well, e.g., add:
-L/opt/local/lib -lglfw3
If you have the pkgconfig port installed, you can also take advantage of that with:
clang `pkg-config glfw3 --cflags` test.c -o test \
`pkg-config glfw3 --static --libs`
You may not need the --static flag if you have: libglfw3.dylib, as opposed to using: libglfw3.a, but it doesn't hurt.
If you are using Xcode, you must add the libglfw3.a library when linking binaries.
Heres the trick
Show hidden folders. Paste this into terminal: defaults write com.apple.finder AppleShowAllFiles YES
Relaunch a finder window and navigate to Macintosh HD\usr
Drag the usr folder to the "Favorites" side in the terminal
In xcode, click the add "+" to link binaries, then click "Add Other"
navigate to the libglfw3.a and add it!
If it still does not work, here are some instructions that helped me.
https://engineering-game-dev.com/2013/08/14/glfw-compiling-source-and-creating-an-xcode-project/comment-page-1/#comment-1400

SFML 2.1 Undefined symbols for architecture x86_64 error

I have recently installed SFML 2.1 and am trying to compile and run from the terminal, NOT Xcode, the sample program that they have on their website at http://www.sfml-dev.org/tutorials/2.0/start-linux.php.
Path to where I installed SFML:
/Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal
However, I keep getting the error of:
Undefined symbols for architecture x86_64:
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in window-48cb4a.o
After googling it, I came across this question: SFML 2.1 RenderWindow linking error
In the accepted answer, the person said that if I wanted to use g++, I had to download the "GCC" version. So, I proceeded to download the GCC - universal 32+64 bits (OS X 10.5+) version and then followed the instructions for installing and compiling SFML on linux, since there were none for mac (http://www.sfml-dev.org/tutorials/2.0/start-linux.php) by doing the following:
Since I had installed SFML in a non-standard location, I told my compiler where to find the header files like so:
-I /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/Frameworks/SFML.framework/Headers
I also had to tell my compiler where to find the SMFL libraries:
-L /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib
I needed to also tell the library loader where to find the SFML libraries from:
export LD_LIBRARY_PATH=/Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib
Then, I put the sfml-audio.framework, sfml-window.framework, sfml-graphics.framework, sfml-network.framework, and sfml-system.framework in my Frameworks directory (/Library/Frameworks).
Finally, I tried to compile my program in the following ways:
g++ window.cpp -I /Users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/Frameworks/SFML.framework/Headers/SFML -L /users/.../Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib -framework sfml-graphics -framework sfml-window -framework sfml-system
g++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system
But, I keep getting the same error. I have continued to google the error, but all I keep getting are questions where people are using Xcode and not the terminal. Any help would be greatly appreciated!
I figured it out at last! First off, as Joachim Pileborg pointed out, I need to install the clang version of SFML for mac since I was using g++ to compile which is clang++ in disguise, as Joachim Pileborg also pointed out. Next, I had to go through the instructions again for setting up SFML with Linux (http://www.sfml-dev.org/tutorials/2.0/start-linux.php).
However, the icing on the cake was when I read this question:
OSX GCC how to specify sfml library source?
...and this question:
FreeType error when building in XCode
...which got me thinking: maybe I should try moving my freetype.framework folder (which can be found in the extlibs directory) into my /Library/Frameworks directory. Once I did this and compiled using
g++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system
It compiled and ran successfully!!! I am very happy now!

What am I missing in my compilation / linking stage of this C++ FreeType GLFW application?

g++ -framework OpenGL GLFT_Font.cpp test.cpp -o test -Wall -pedantic -lglfw -lfreetype - pthread `freetype-config --cflags`
Undefined symbols:
"_GetEventKind", referenced from:
__glfwKeyEventHandler in libglfw.a(macosx_window.o)
__glfwMouseEventHandler in libglfw.a(macosx_window.o)
__glfwWindowEventHandler in libglfw.a(macosx_window.o)
"_ShowWindow", referenced from:
__glfwPlatformOpenWindow in libglfw.a(macosx_window.o)
"_MenuSelect", referenced from:
This is on Mac OS X.
I am trying to get GLFT_FONT to work on MacOSX with GLFW and FreeType2. This is not the standard Makefile. I changed parts of it myself (like the "-framework OpenGL"
I am from Linux land, a bit new to Mac.
I am on Mac OS X 10.5.8; using XCode 3.1.3
Thanks!
I tink those come from the Carbon framework.
LIBS += -framework Carbon
should do it then.
You need to link against the Carbon and AGL frameworks as well, i.e.
-framework AGL -framework Carbon
Also note that GLFW 2.6 only works as 32-bit on Mac OS X.