Undefined symbols for architecture x86_64 "_r8_huge_" - fortran

I have a .f90 file which I compile with:
gfortran -c -o objs/mod_interp.o ../extern/mod_interp.f90 -g -fPIC -Imods -I../header_files -Jmods
The rest of the objects are compiled from F77 files, and then everything is linked with:
gfortran -o WIM2d.exec objs/p_WIM2d.o objs/mod_WIM2d_run.o objs/mod_interp.o objs/mod_file_utils.o objs/mod_gridinfo.o objs/mod_wim_init.o objs/mod_common_wim.o objs/mod_wim_prams.o objs/RTparam_outer.o objs/RTparam_fast.o objs/RTparam_hardcoded_v2.o objs/mod_RTparam_utilities.o objs/mod_adv_atten.o objs/mod_advect.o objs/mod_wavesice.o -g -fPIC -Imods -I../header_files
However I get the following error:
Undefined symbols for architecture x86_64:
"_r8_huge_", referenced from:
___mod_interp_MOD_pwl_interp_2d in mod_interp.o
"_r8vec_bracket5_", referenced from:
___mod_interp_MOD_pwl_interp_2d in mod_interp.o
ld: symbol(s) not found for architecture x86_64
I am working on a mac with OSX 10.10.
Any suggestions?

Related

Compiling error with MPFR package on mac

When I try to compile the newly installed package MPFR I get the following error:
Undefined symbols for architecture x86_64:
"_mpfr_init2", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I use Codelite on a macbook pro and I think I successfully installed the package using the instruction on the website.
Any ideas on how to solve it?
From the limited information given, I suspect that you are not linking the MPFR library during the linking phase of main.cpp. What is the exact command you are using?
Make sure that -lmpfr is passed at the end of the clang++ command, like so:
clang++ main.cpp -lmpfr
or:
clang++ main.cpp -c
clang++ main.o -lmpfr
If libmpfr.so is installed in a nonstandard place, then you need to tell the compiler where, using the -L option:
clang++ main.cpp -L"$MPFR_PATH" -lmpfr
or:
clang++ main.cpp -c
clang++ main.o -L"$MPFR_PATH" -lmpfr
If not, then please provide more information.

Trouble building and using Lua for 32-bit on 64-bit OS X

I'm having difficulties using my built Lua.
To build my small project, I'm using:
gcc -m32 -arch i386 -I ~/Documents/lua-5.1.4/include -L ~/Documents/lua-5.1.4/lib -llua -mconsole -sectcreate __TEXT __info_plist ./Info.plist -o LuaProject -masm=intel LuaProject.cpp
I built Lua with "make macosx test". To try to make it build 32-bit, I modified the src/Makefile so that the top became:
CC= gcc
CFLAGS= -m32 -arch i386 -O2 -Wall $(MYCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
LIBS= -lm $(MYLIBS)
MYCFLAGS=
MYLDFLAGS= -m32 -arch i386
MYLIBS=
That seemed to make it for 32-bit. All I did was add -m32 -arch i386 to CFLAGS (MYCFLAGS wasn't affecting anything) and -m32 -archi386 to MYLDFLAGS. After it worked for neither -m32 nor -arch i386 individually I added both (perhaps not the best logic) which changed nothing. The build works, so then I "sudo make install local", which creates the nice folders I used to try to compile my project.
The output from gcc ends up being:
Undefined symbols for architecture i386:
"luaL_newstate()", referenced from:
_main in LuaProject-15f700.o
"luaL_openlibs(lua_State*)", referenced from:
_main in LuaProject-15f700.o
"luaL_loadbuffer(lua_State*, char const*, unsigned long, char const*)", referenced from:
_main in LuaProject-15f700.o
"lua_pcall(lua_State*, int, int, int)", referenced from:
_main in LuaProject-15f700.o
ld: symbol(s) not found for architecture i386
I am hopefully including all I need to (lua.h, lauxlib.h, lualib.h) and no errors are thrown about the -llua itself, so I am confused as to why this isn't working.
I didn't want to clutter the question with the full Lua makefile but I can upload it if needed.

XCode unable to compile Poco project, undefined symbols

I've been looking for a proper HTTP parser in C++ and today I found that Poco has support for both parsing HTTP requests, setting up a server and also setting up a HTTPS server along with other cool features and I'm eager to start using it.
I've got a problem with compiling a small example though, the project is setup as a stdc++11 project, I've set the header and library search path to /usr/local/include and /usr/local/lib and have linked the libraries themselves in the Other Linker Flags in this order "-lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -lPocoJSON" the order of which doesn't seem to matter.
The code itself doesn't throw any errors within XCode, it's just when I try to compile it I get these reference errors, I've fixed 38 others of them by adding the libraries to the Other Linker Flags option but these two errors won't go away.
The error I'm getting is the following
Ld /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug/NitroServer normal x86_64
cd /Users/zezioen/stack/Projecten/CPP/NitroServer
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug -L/Users/zezioen/stack/Projecten/CPP/NitroServer/lib -L/usr/local/lib -F/Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug -F/Users/zezioen/stack/Projecten/CPP/NitroServer/lib -filelist /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Intermediates/NitroServer.build/Debug/NitroServer.build/Objects-normal/x86_64/NitroServer.LinkFileList -mmacosx-version-min=10.11 -Xlinker -no_deduplicate -lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -lPocoJSON -stdlib=libstdc++ -Xlinker -dependency_info -Xlinker /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Intermediates/NitroServer.build/Debug/NitroServer.build/Objects-normal/x86_64/NitroServer_dependency_info.dat -o /Users/zezioen/Library/Developer/Xcode/DerivedData/NitroServer-gpnzdaqmezqcauegsmrabobsxotk/Build/Products/Debug/NitroServer
Undefined symbols for architecture x86_64:
"Poco::Net::HTTPMessage::setContentType(std::string const&)", referenced from:
MyRequestHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&) in main.o
"Poco::Util::Application::handleOption(std::string const&, std::string const&)", referenced from:
vtable for MyServerApp in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What do I have to do in order to get the project to build?
Resolved here - POCO is linked with libc++, application was linking with libstdc++.

linking C++ programs to Python

For linking C++ and python I used the following commands:
Compiling the actual function:
g++ -c -fpic main.cpp
Generate the wrapping C code using SWIG:
swig -c++ -python main.i
Compile the wrapping C code:
g++ -c -fpic main_wrap.cxx -I/usr/include/python2.7
for Linking everything together I used these tow instruction:
1) g++ -shared main.o main_wrap.o -o _main.so
2) g++ -lpython -shared main.o main_wrap.o -o _main.so
and got errors in both but less in the second one. (for the func.c example I checked and it only be linked with -lpython flag be set!)
however, it still gives me following errors:
Undefined symbols for architecture x86_64:
"std::vector<double, std::allocator<double> > power_method<double>(double, int)", referenced from:
__wrap_power_methodDouble in main_wrap.o
"std::vector<float, std::allocator<float> > power_method<float>(float, int)", referenced from:
__wrap_power_methodFloat in main_wrap.o
"std::vector<int, std::allocator<int> > power_method<int>(int, int)", referenced from:
__wrap_power_methodInt in main_wrap.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Show message history

Error building simple Qt5 application

I installed Qt 5.0.0 (qt-mac-opensource-5.0.0-clang-offline.dmg) on a Mac OS X 10.7.5 and now I'm trying to compile a "Hello World" application using Qt Creator 2.6.1.
The build process complains about a directory not found: /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib , followed by several linking errors:
clang++ -c -pipe -mmacosx-version-min=10.6 -O2 -Wall -W -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/mkspecs/macx-clang -I. -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include/QtGui -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/include/QtCore -I/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -o main.o main.cpp
clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o hello_qt.app/Contents/MacOS/hello_qt main.o -F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib -framework QtGui -F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib -framework QtCore -framework OpenGL -framework AGL
ld: warning: directory not found for option '-F/Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib'
Undefined symbols for architecture x86_64:
"QApplication::QApplication(int&, char**, int)", referenced from:
_main in main.o
"QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)", referenced from:
_main in main.o
"QWidget::show()", referenced from:
_main in main.o
"QPushButton::QPushButton(QString const&, QWidget*)", referenced from:
_main in main.o
"QApplication::exec()", referenced from:
_main in main.o
"QPushButton::~QPushButton()", referenced from:
_main in main.o
"QLabel::~QLabel()", referenced from:
_main in main.o
"QApplication::~QApplication()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [hello_qt.app/Contents/MacOS/hello_qt] Error 1
It's important to note that the path /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/qtbase/lib is not valid because the directory qtbase doesn't exist. The working path is /Users/karlphillip/Qt5.0.0/5.0.0/clang_64/lib. I'm not referring to qtbase anywhere in my project, so this is probably being added by qmake.
As it turns out, the invalid qtbase path thing is really a Qt bug originally reported at QTBUG-28336.
The linking problem is due to my project not linking with QtWidgets, which is something we are going to have to do starting in Qt5. This is accomplished by adding the following line to your .pro file:
QT += widgets
i had the same problem and to be honest im not shure how i managed it to solve.
i think/guess i copied the needed folders from the sources into the matching 'clang_64' folders and that does the job.
soo long zai