I'm trying to run some MPI programs in xcode 4. I installed openmpi from MacPort by typing sudo port install openmpi and the installation finished normally. Then I added opt/local/include/openmpi to my user header search paths, dragged the "libmpi.dylib" and "libmpi_cxx.dylib" into my project.
But then when I tried to run the program, I got the following error message:
Undefined symbols for architecture x86_64:
"_MPI_Comm_accept", referenced from:
MPI::Intracomm::Accept(char const*, MPI::Info const&, int) const in main.o
"_MPI_Comm_connect", referenced from:
MPI::Intracomm::Connect(char const*, MPI::Info const&, int) const in main.o
"_MPI_Comm_disconnect", referenced from:
MPI::Comm::Disconnect() in main.o
"_MPI_Comm_get_errhandler", referenced from:
MPI::Comm::Get_errhandler() const in main.o
"_MPI_Comm_set_errhandler", referenced from:
MPI::Comm::Set_errhandler(MPI::Errhandler const&) const in main.o
"_MPI_Comm_spawn", referenced from:
MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int) const in main.o
MPI::Intracomm::Spawn(char const*, char const**, int, MPI::Info const&, int, int*) const in main.o
"_MPI_Comm_spawn_multiple", referenced from:
MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int) in main.o
MPI::Intracomm::Spawn_multiple(int, char const**, char const***, int const*, MPI::Info const*, int, int*) in main.o
"_MPI_Grequest_complete", referenced from:
MPI::Grequest::Complete() in main.o
"_MPI_Op_commutative", referenced from:
MPI::Op::Is_commutative() const in main.o
"_MPI_Reduce_local", referenced from:
MPI::Op::Reduce_local(void const*, void*, int, MPI::Datatype const&) const in main.o
"_MPI_Win_call_errhandler", referenced from:
MPI::Win::Call_errhandler(int) const in main.o
"_MPI_Win_get_errhandler", referenced from:
MPI::Win::Get_errhandler() const in main.o
"_MPI_Win_set_errhandler", referenced from:
MPI::Win::Set_errhandler(MPI::Errhandler const&) const in main.o
"_ompi_mpi_comm_null", referenced from:
MPI::Intracomm::Intracomm(ompi_communicator_t*) in main.o
MPI::Graphcomm::Graphcomm(ompi_communicator_t* const&) in main.o
MPI::Cartcomm::Cartcomm(ompi_communicator_t* const&) in main.o
"_ompi_mpi_comm_world", referenced from:
_main in main.o
"_ompi_mpi_double", referenced from:
_main in main.o
"_ompi_mpi_op_sum", referenced from:
_main in main.o
"_ompi_op_set_cxx_callback", referenced from:
MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool) 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)
Am I missing anything in the above installation processes?
First be sure to have installed MPI.
I personally use brew to do so.
brew update
brew install open-mpi
Then check the requirements for c++:
mpic++ -showme
or mpicc -showme for c
My output with mpic++ is :
clang++ -I/usr/local/Cellar/open-mpi/1.8.6/include -L/usr/local/opt/libevent/lib -L/usr/local/Cellar/open-mpi/1.8.6/lib -lmpi_cxx -lmpi
Then we got the include path, library path and some other flags. From the output of the previous command we got that we need to add:
"/usr/local/Cellar/open-mpi/1.8.6/include" in the “Search Paths – Header Search Paths”
"/usr/local/opt/libevent/lib" and "/usr/local/Cellar/open-mpi/1.8.6/lib" in the “Search Paths – Library Search Paths”
"-lmpi_cxx -lmpi" in the “Linking – Other Linker Flags”
These can be done through the Build Settings option from the Xcode project.
Because mpi need to use it's own program to run ours we need to change the Executable.
Select "Edit schemes"
In the dialog box under Info for the Executable choose Other... from the combobox.
Change it to mpiexec wich is an alias of "orterun". For me it's in /usr/local/Cellar/open-mpi/1.8.6/bin. Note that this is usually an hidden folder. You can open it by pressing cmd + shift + g.
For running mpiexec need to know as arguments the number of processors and the executable file. So, in the same dialog box under Arguments
add "-n X" where X is the number of processors you want to use "for this example i will use 2".
add "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH" wich is the combination of environment variables that specify the executable file.
Then add <mpi.h> header to your source code.
Run it and you will see 2 "Hello, World!" (because I use -n 2 for the example).
sources : open-mpi xcode FAQ, Debugging & running MPI programs in Xcode
I had the same problem, when I compiled openmpi from the sources, added header and library search paths, but forgot to add libraries as the linker flags to the build settings. Adding them solved this. You can type mpicc –showme to see the libraries that are necessary for mpi to run.
Or just type mpic++ instead of mpicc. That worked for me ;)
Related
I am new to c++. When I build my main.cpp on Xcode, I got this message:
Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
_main in main.o
print_attributes(IDeckLink*) in main.o
print_output_mode(char const*, unsigned int, IDeckLinkDisplayMode*, IDeckLinkOutput*) in main.o
print_input_mode(char const*, unsigned int, IDeckLinkDisplayMode*, IDeckLinkInput*) in main.o
"_CFStringGetCString", referenced from:
_main in main.o
print_attributes(IDeckLink*) in main.o
print_output_mode(char const*, unsigned int, IDeckLinkDisplayMode*, IDeckLinkOutput*) in main.o
print_input_mode(char const*, unsigned int, IDeckLinkDisplayMode*, IDeckLinkInput*) in main.o
"_CreateDeckLinkIteratorInstance", referenced from:
_main in main.o
I researched on stackoverflow and found Alex Reche Martinez suggested adding "-framework CoreFoundation" to the link command line of the project. But I don't know which file contains the link command line. Can anyone help? Thank you in advance!
I am trying to SNAP with C++ on Xcode. I installed SNAP and provided these two header search paths to Xcode: /usr/local/Cellar/Snap-3.0/snap-core/ and /usr/local/Cellar/Snap-3.0/glib-core/.
But it still produces the error below. I believe I need to fill in "other linker flags" in Xcode, but I can't seem to get it right. Thanks for help.
The C++ Code is below:
#include "Snap.h"
int main() {
return 0;
}
Error Message Below
Undefined symbols for architecture x86_64:
"ExeStop(char const*, char const*, char const*, char const*, int const&)", referenced from:
TRStr::UnRef() in main.o
TRStr::~TRStr() in main.o
TRStr::GetNullRStr() in main.o
"TStr::GetRStr(char const*)", referenced from:
TStr::TStr(char const*) 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)**
It works once I add -lSnap.o in "other linker flags" in Xcode
I'm working with an external code in my project which I have access to the headers and the .cc files but I don't have any access to .dylibs. I'm getting some errors, related to link of the libs, that is described bellow.
This code runs perfectly well if I run it directly from the terminal. The problem only occured when I tried to incorporate it on my own project (that have other modules) in XCode. I guess that if I add the .dylib files to XCode it will solve the problem. However, I don't have the .dylibs. How can I put this code to run?
Undefined symbols for architecture x86_64:
"FACETRACKER::IO::LoadCon(char const*)", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::IO::LoadTri(char const*)", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::CLM::GetViewIdx()", referenced from:
mark(int, char const**) in main.o
"FACETRACKER::FDet::~FDet()", referenced from:
FACETRACKER::Tracker::~Tracker() in main.o
FACETRACKER::Tracker::Tracker(char const*) in main.o
"FACETRACKER::Tracker::Load(char const*)", referenced from:
FACETRACKER::Tracker::Tracker(char const*) in main.o
"FACETRACKER::Tracker::Track(cv::Mat, std::__1::vector<int, std::__1::allocator<int> >&, int, int, double, double, bool)", referenced from:
mark(int, char const**) 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)
Problem was solved by adding .dylib files (boost) to project.
I'm trying connect Boost 1.55 to Xcode 5 through Homebrew.
Brew installed it as it should. In /usr/local/include && /usr/local/lib appeared aliases on Boost headers and libraries.
Xcode "Search Path" settings:
http://i.imgur.com/j5GJ0sh.png
http://i.imgur.com/DXRxiyA.png
But when I tried compile simple example:
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main()
{
const regex expression( "How to re" );
string string1 = "How to re";
bool match=regex_match(string1,expression);
if (match){
cout<<"Yes"<<endl;
}
return 0;
}
Errors:
Undefined symbols for architecture x86_64: "boost::basic_regex >
::do_assign(char const*, char const*, unsigned int)", referenced from:
boost::basic_regex > >::assign(char const*, char const*,
unsigned int) in main.o "boost::re_detail::get_mem_block()",
referenced from:
boost::re_detail::perl_matcher,
std::__1::allocator > >, boost::regex_traits >
::extend_stack() in main.o
boost::re_detail::save_state_init::save_state_init(boost::re_detail::saved_state**,
boost::re_detail::saved_state**) in main.o
"boost::re_detail::put_mem_block(void*)", referenced from:
boost::re_detail::save_state_init::~save_state_init() in main.o
boost::re_detail::perl_matcher,
std::__1::allocator > >, boost::regex_traits >
::unwind_extra_block(bool) in main.o "boost::re_detail::verify_options(unsigned int,
boost::regex_constants::_match_flags)", referenced from:
boost::re_detail::perl_matcher,
std::__1::allocator > >, boost::regex_traits >
::match_imp() in main.o "boost::re_detail::raise_runtime_error(std::runtime_error const&)",
referenced from:
void boost::re_detail::raise_error > >
(boost::regex_traits_wrapper > > const&,
boost::regex_constants::error_type) in main.o
"boost::re_detail::get_default_error_string(boost::regex_constants::error_type)",
referenced from:
boost::re_detail::cpp_regex_traits_implementation::error_string(boost::regex_constants::error_type)
const in main.o
"boost::re_detail::cpp_regex_traits_implementation::transform_primary(char const*, char const*) const", referenced from:
boost::cpp_regex_traits::transform_primary(char const*, char const*) const in main.o
"boost::re_detail::cpp_regex_traits_implementation::transform(char
const*, char const*) const", referenced from:
boost::cpp_regex_traits::transform(char const*, char const*) const 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)
Really tired with it, so, ask for your help.
Thank you,
- Philipp
You have a few options but all of them involve adding the library libboost_regex to your project to resolve the link errors. Even though you installed boost using homebrew, you still need to add the library to your project because boost's regex code contains a compiled portion. If you don't add the library there is no way for the linker to resolve the symbols.
The first option is to add /usr/local/lib to Library Search Paths, and add -lboost_regex to Other Linker Flags. If you choose this option you may need to add /usr/local/lib to Runpath Search Paths also. This method will link against the dynamic library in /usr/local/lib.
If you want your program to be self-contained you can link against the static (.a) version of boost_regex. To do this add libboost_regex.a to your project in Build Settings - Link Binary With Libraries.
I'm trying to use some frameworks with Xcode 4.6.2.
C++ frameworks, such as cppunit and boost that is supposed to be compiled and linked to in my projects always fails with "Undefined symbols for architecture x86_64[...]" or i386 for that matter when I'm trying different build settings.
I have tried setting Compiler to clang and g++ with various sets of cpu-architecture flags (64, 32 and 32_64). I have come to a point where I can't find any solutions on my own.
I've also tried the fail safe packages from without any luck:
brew install cppunit universal
port install cppunit +universal
(Also without success the Boost library)
Also, a lot of tries on Boost is done. Bjam has really made a lot of work the last 24 hours. Multiple settings has been tried:
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode and
http://boost.2283326.n4.nabble.com/Errors-compiling-Boost-Log-on-OS-X-tp4646151p4646299.html
And more in pure trial and error on my part.
So my question is: what are the combination of compiler and linker and the respective flags I should use in order to make it work in my Xcode projects?
Per request from Captain Obvlious, here are some errors when running an application with Boost::Test:
Undefined symbols for architecture x86_64:
"boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned long, ...)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char const>, unsigned long, boost::unit_test::basic_cstring<char const>)", referenced from:
my_test::test_method() in main.o
"boost::unit_test::framework::master_test_suite()", referenced from:
init_unit_test_suite(int, char**) in main.o
"boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>, boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, unsigned long)", referenced from:
___cxx_global_var_init2 in main.o
"boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char const>)", referenced from:
boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&, boost::unit_test::basic_cstring<char const>) in main.o
"vtable for boost::unit_test::unit_test_log_t", referenced from:
boost::unit_test::unit_test_log_t::unit_test_log_t() in main.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to add whichever library those functions depend on via "Link Binary With Libraries" in the Build Phases of your Project. However, this then brings up the dreaded EXC_BAD_ACCESS you can read about elsewhere on Stack.