I am trying to compile this code mentioned below.
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTTPMessage.h"
#include "Poco/Net/WebSocket.h"
#include "Poco/Net/HTTPClientSession.h"
#include <iostream>
using Poco::Net::HTTPClientSession;
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPMessage;
using Poco::Net::WebSocket;
int main(int args,char **argv)
{
HTTPClientSession cs("echo.websocket.org",80);
HTTPRequest request(HTTPRequest::HTTP_GET, "/?encoding=text",HTTPMessage::HTTP_1_1);
request.set("origin", "http://www.websocket.org");
HTTPResponse response;
try {
WebSocket* m_psock = new WebSocket(cs, request, response);
char *testStr="Hello echo websocket!";
char receiveBuff[256];
int len=m_psock->sendFrame(testStr,strlen(testStr),WebSocket::FRAME_TEXT);
std::cout << "Sent bytes " << len << std::endl;
int flags=0;
int rlen=m_psock->receiveFrame(receiveBuff,256,flags);
std::cout << "Received bytes " << rlen << std::endl;
std::cout << receiveBuff << std::endl;
m_psock->close();
} catch (std::exception &e) {
std::cout << "Exception " << e.what();
}
but it is not compiling in terminal even though i installed the poco libraries in my PC by using the following commands:
$ git clone -b master https://github.com/pocoproject/poco.git
$ cd poco
$ mkdir cmake-build
$ cd cmake-build
$ cmake ..
$ cmake --build . --config Release
$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/mytoolchain.cmake -DCMAKE_INSTALL_PREFIX=/path/to/target
$ sudo cmake --build . --target install
The default install location is /usr/local/ on Linux and macOS and C:\Program Files (x64)\ on Windows and can be overridden by setting the CMAKE_INSTALL_PREFIX CMake variable.
here are the errors showing after compiling it with this command in terminal::-->g++ -Wall -std=c++11 EchoRequest.cpp -o echo
where EchoRequest.cpp is the file name and echo is the i mentioned for compiled file
Here are errors showing-->
Undefined symbols for architecture arm64:
"Poco::Net::HTTPMessage::HTTP_1_1", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPRequest::HTTP_GET", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPRequest::HTTPRequest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPRequest::~HTTPRequest()", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPResponse::HTTPResponse()", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPResponse::~HTTPResponse()", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPClientSession::HTTPClientSession(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned short)", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::HTTPClientSession::~HTTPClientSession()", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::NameValueCollection::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::WebSocket::receiveFrame(void*, int, int&)", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::WebSocket::sendFrame(void const*, int, int)", referenced from:
_main in EchoRequest-11faf4.o
"Poco::Net::WebSocket::WebSocket(Poco::Net::HTTPClientSession&, Poco::Net::HTTPRequest&, Poco::Net::HTTPResponse&)", referenced from:
_main in EchoRequest-11faf4.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
any help me out with this error. I checked in online it is showing the solutions for cpp IDE's and afterr exploring I got to know it is a OS error so what to do to rectify this error.
can anyone suggest a command line for compiling it properly or any required changes that must be need to do it as per the OS.
please help me out if anyone knows the answers
Related
I'm trying to run a simple c++ program that open a window using the SFML library in Xcode 13
#include <iostream>
#include <SFML/Window.hpp>
int main(int argc, const char * argv[]) {
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");
return 0;
}
When i try to run it under native arm64 at compile time show this error:
Undefined symbols for architecture arm64:
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in main.o
"sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in main.o
"sf::Window::~Window()", referenced from:
_main in main.o
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And when I try to run it under rosetta (x86_64) show this:
Undefined symbols for architecture x86_64:
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in main.o
"sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in main.o
"sf::Window::~Window()", referenced from:
_main in main.o
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", 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)
Idk what to do, I'm new to c++. THANKS
I want to use rpclib from here. I started a new project with main.cpp and CMakeLists.txt and copied the rpclib as a subdirectory into my project:
My code is exactly the example from rpclib and looks like this:
#include <iostream>
#include "rpc/server.h"
void foo() {
std::cout << "foo was called!" << std::endl;
}
int main(int argc, char *argv[]) {
// Creating a server that listens on port 8080
rpc::server srv(8080);
// Binding the name "foo" to free function foo.
// note: the signature is automatically captured
srv.bind("foo", &foo);
// Binding a lambda function to the name "add".
srv.bind("add", [](int a, int b) {
return a + b;
});
// Run the server loop.
srv.run();
return 0;
}
and my CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.16)
project(RPC_Test)
set(CMAKE_CXX_STANDARD 14)
add_subdirectory(rpclib)
include_directories(rpclib/include)
add_executable(RPC_Test main.cpp)
As I understood, the line add_subdirectory(rpclib) takes care of adding the rpclib and builds its content during building the RPC_Test-Project. It seems, I am wrong. Nothing within rpclib gets build and the build-process RPC_Test fails with a linker-error:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/seba/CLionProjects/rpc-cpp/cmake-build-debug-system --target RPC_Test -- -j 3
Scanning dependencies of target RPC_Test
[ 50%] Building CXX object CMakeFiles/RPC_Test.dir/main.cpp.o
[100%] Linking CXX executable RPC_Test
Undefined symbols for architecture x86_64:
"rpc::detail::dispatcher::enforce_arg_count(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, unsigned long)", referenced from:
void rpc::detail::dispatcher::bind<void (*)()>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, void (*)(), rpc::detail::tags::void_result const&, rpc::detail::tags::zero_arg const&)::'lambda'(clmdep_msgpack::v2::object const&)::operator()(clmdep_msgpack::v2::object const&) const in main.cpp.o
void rpc::detail::dispatcher::bind<main::$_0>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, main::$_0, rpc::detail::tags::nonvoid_result const&, rpc::detail::tags::nonzero_arg const&)::'lambda'(clmdep_msgpack::v2::object const&)::operator()(clmdep_msgpack::v2::object const&) const in main.cpp.o
"rpc::detail::dispatcher::enforce_unique_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
void rpc::detail::dispatcher::bind<void (*)()>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, void (*)()) in main.cpp.o
void rpc::detail::dispatcher::bind<void (*)()>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, void (*)(), rpc::detail::tags::void_result const&, rpc::detail::tags::zero_arg const&) in main.cpp.o
void rpc::detail::dispatcher::bind<main::$_0>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, main::$_0) in main.cpp.o
void rpc::detail::dispatcher::bind<main::$_0>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, main::$_0, rpc::detail::tags::nonvoid_result const&, rpc::detail::tags::nonzero_arg const&) in main.cpp.o
"rpc::server::run()", referenced from:
_main in main.cpp.o
"rpc::server::server(unsigned short)", referenced from:
_main in main.cpp.o
"rpc::server::~server()", referenced from:
_main in main.cpp.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[3]: *** [RPC_Test] Error 1
make[2]: *** [CMakeFiles/RPC_Test.dir/all] Error 2
make[1]: *** [CMakeFiles/RPC_Test.dir/rule] Error 2
make: *** [RPC_Test] Error 2
What is missing?
You're missing a target_link_libraries(RPC_Test PRIVATE rpc) after the definition of the RPC_Test target . rpc here is the name of the library target defined in rpclib's CMakeLists.txt, not just the base name of the resulting binary artifact.
When using a target name with target_link_libraries like that CMake will not only add -lrpc to the linker invocation, but also automatically add the include directories necessary to use the library and ensure that the rpc library is built before RPC_Test. In particular, this means you can also remove the include_directories call when you use target_link_libraries(RPC_Test PRIVATE rpc).
I followed the instruction on thier github https://github.com/openvinotoolkit/openvino to build it on macOS, done it and when i wrote a small code to check was all clear or not
#include <string>
#include <iostream>
#include <dlfcn.h>
#include <fstream>
#define USE_STATIC_IE
#define _CRT_SECURE_NO_WARNINGS
#include <ie_core.hpp>
using namespace :: std;
int main(){
dlopen("/Users/nk/Documents/HZ/openvino/inference-engine/temp/tbb/lib/libtbb.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libngraph.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_transformations.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_legacy.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_lp_transformations.dylib", RTLD_LAZY);
dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libMKLDNNPlugin.dylib", RTLD_LAZY);
const std::string pluginsFilePath = "/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/plugins.xml";
InferenceEngine::Core ie(pluginsFilePath);
const auto info = ie.GetVersions("CPU");
if(!info.empty())
cout << "Yes";
return 0;
}
when i compile it with command
g++ -std=c++11 -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll
it gave me the error
Undefined symbols for architecture x86_64:
"InferenceEngine::Core::Core(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in testdll-788073.o
"InferenceEngine::Core::GetVersions(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
_main in testdll-788073.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
then i added .a libs and ran this command
g++ -std=c++11 -L/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib -lmkldnn -lpugixml -linference_engine_s -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll
and i got this
Undefined symbols for architecture x86_64:
"ngraph::as_output_vector(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&)", referenced from:
ngraph::Node::generate_adjoints(ngraph::autodiff::Adjoints&, std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::match_node(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::match_value(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&, ngraph::Output<ngraph::Node> const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::constant_fold(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > >&, std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::set_arguments(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::set_output_type(unsigned long, ngraph::element::Type const&, ngraph::PartialShape const&)", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::m_next_instance_id", referenced from:
std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::validate_and_infer_types()", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::evaluate(std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&, std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&)", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::~Node()", referenced from:
ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_dynamic() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::description() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_constant() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_arguments() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_size() const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::write_description(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int) const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::copy_with_new_args(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_element_type(unsigned long) const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_default_output_index() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_output_partial_shape(unsigned long) const", referenced from:
ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::get_autob() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"ngraph::Node::is_output() const", referenced from:
vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"typeinfo for ngraph::Node", referenced from:
typeinfo for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
"vtable for ngraph::Node", referenced from:
std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.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)
Did anyone had the same problem as me, and did anyone know how to fix it?
First and foremost just need to cross check with you on your toolkit installation. Since you are trying to run a model already, I assume you already set it up properly as in (fyi latest version is 2020.4): https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
The error that you are getting, the Undefined symbols for architecture x86_64 is an Xcode build failure indicating you missed out something in your inference engine or the way you link the model with certain resources are incorrect or some other reasons. As long as this error persist you won't be able to compile your code. That is why you got the linker command failed with exit code 1.
Most error occurs because the users did not Set the OpenVINO environment variables or Configure the Model Optimizer correctly. This is why it's really important to Run verification scripts to verify installation and compile samples.
Before running any custom model, it is good to have a solid working Openvino environment, hence please help to check whether you could run the default models as in example here https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
By default, you should already have pre-trained models including open zoo model, Model Optimizer and Inference Engine which are working example to work with if you configured the toolkit correctly. These should already located in your installed toolkit's directory which you don't have to install separately from other resources.
Please take a note that you need:
CMake 3.4 or higher,
Python 3.5 or higher,
Apple Xcode Command Line Tools*,
(Optional) Apple Xcode* IDE (not required for OpenVINO, but useful for development),
And supported MAC OS is macOS 10.14.4*
Again, please help to cross check what you have in your Openvino environment and steps you had used to configure with the official documentation https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html
Thanks!
In the project I'm working on, I'm trying to use the curlpp library to make a simple html GET request. I pass the cpp file to clang++ with the following options:
clang++ -std=c++11 -stdlib=libc++ -I /usr/local/Cellar url_test.cpp
I then get these errors:
Undefined symbols for architecture x86_64:
"curlpp::OptionBase::OptionBase(CURLoption)", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Option(CURLoption, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in url_test-541b93.o
"curlpp::OptionBase::~OptionBase()", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Option(CURLoption, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in url_test-541b93.o
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~Option() in url_test-541b93.o
"curlpp::UnsetOption::UnsetOption(char const*)", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::updateMeToOption(curlpp::OptionBase const&) in url_test-541b93.o
curlpp::OptionTrait<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (CURLoption)10002>::updateHandleToMe(curlpp::internal::CurlHandle*) const in url_test-541b93.o
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::getValue() const in url_test-541b93.o
"curlpp::RuntimeError::~RuntimeError()", referenced from:
curlpp::UnsetOption::~UnsetOption() in url_test-541b93.o
"curlpp::libcurlRuntimeAssert(char const*, CURLcode)", referenced from:
void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*) in url_test-541b93.o
"curlpp::Easy::perform()", referenced from:
_main in url_test-541b93.o
"curlpp::Easy::Easy()", referenced from:
_main in url_test-541b93.o
"curlpp::Easy::~Easy()", referenced from:
_main in url_test-541b93.o
"curlpp::Cleanup::Cleanup()", referenced from:
_main in url_test-541b93.o
"curlpp::Cleanup::~Cleanup()", referenced from:
_main in url_test-541b93.o
"curlpp::OptionBase::operator<(curlpp::OptionBase const&) const", referenced from:
vtable for curlpp::OptionTrait<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (CURLoption)10002> in url_test-541b93.o
vtable for curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in url_test-541b93.o
"typeinfo for curlpp::LogicError", referenced from:
GCC_except_table0 in url_test-541b93.o
"typeinfo for curlpp::OptionBase", referenced from:
curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::updateMeToOption(curlpp::OptionBase const&) in url_test-541b93.o
typeinfo for curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in url_test-541b93.o
"typeinfo for curlpp::RuntimeError", referenced from:
GCC_except_table0 in url_test-541b93.o
typeinfo for curlpp::UnsetOption in url_test-541b93.o
"_curl_easy_setopt", referenced from:
void curlpp::internal::CurlHandle::option<void*>(CURLoption, void*) in url_test-541b93.o
ld: symbol(s) not found for architecture x86_64
which I think means that the compiler cannot find any of the curlpp libraries.
Here's the code I'm trying to run:
1 #include <string>
2 #include <sstream>
3 #include <iostream>
4 #include <curlpp/cURLpp.hpp>
5 #include <curlpp/Easy.hpp>
6 #include <curlpp/Options.hpp>
7 #include <fstream>
8
9 using namespace curlpp::options;
10
11 int main(int, char **)
12 {
13 try
14 {
15 curlpp::Cleanup testCleanup;
16 curlpp::Easy miRequest;
17 miRequest.setOpt<Url>("http://www.wikipedia.org");
18 miRequest.perform();
19 }
20 catch(curlpp::RuntimeError & e)
21 {
22 std::cout << e.what() << std::endl;
23 }
24 catch(curlpp::LogicError & e)
25 {
26 std::cout << e.what() << std::endl;
27 }
28
29 return 0;
30 }
I'm running macOS Sierra 10.12.4 with Xcode command line tools and homebrew installed. I homebrew'd the curlpp library. I know that someone else was able to compile this project on Ubuntu 16.04 using gcc, so I think the issue is to do with macOS.
I'm quite new to cpp, so any help would be greatly appreciated!
You have to tell the compiler which libraries to link with your executable. In your case, the issue is solved by adding options -lcurlpp -lcurl.
By the way, the path you provide is not correct since headers actually reside in /usr/local/Cellar/curlpp/[insert version here]/include. Anyways, this compiles fine without adding include search path for libraries installed via homebrew since it automatically creates symlinks in /usr/local/include, which is one of default places for a compiler to search.
Your problem is that you are not linking the library you use. Add the library and you should be good.
I have R 3.0.3 installed with mac ports on OS X 10.9.2. I installed RInside with sudo R CMD INSTALL ~/Downloads/RInside_0.2.11.tgz (similarly Rcpp_0.11.1.tar). I am trying to compile a simple RInside Help World code from http://dirk.eddelbuettel.com/code/rinside.html. I am trying to use
g++ main.cpp -I/Users/robogos/Library/R/3.0/library/RInside/include/ -I/Users/robogos/Library/R/3.0/library/Rcpp/include/ -I/opt/local/Library/Frameworks/R.framework/Versions/3.0/Resources/include/
and I get a long list of errors:
Undefined symbols for architecture x86_64:
"_REprintf", referenced from:
Rcpp::Rstreambuf<false>::xsputn(char const*, long) in main-4b77b4.o
Rcpp::Rstreambuf<false>::overflow(int) in main-4b77b4.o
"_R_BindingIsLocked", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_R_FlushConsole", referenced from:
Rcpp::Rstreambuf<false>::sync() in main-4b77b4.o
Rcpp::Rstreambuf<true>::sync() in main-4b77b4.o
"_R_NilValue", referenced from:
Rcpp::wrap(char const*) in main-4b77b4.o
"_R_UnboundValue", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_defineVar", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
"_Rf_findVarInFrame", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_install", referenced from:
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const in main-4b77b4.o
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::exists(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
Rcpp::Environment_Impl<Rcpp::PreserveStorage>::bindingIsLocked(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in main-4b77b4.o
"_Rf_mkString", referenced from:
Rcpp::wrap(char const*) in main-4b77b4.o
"_Rprintf", referenced from:
Rcpp::Rstreambuf<true>::xsputn(char const*, long) in main-4b77b4.o
Rcpp::Rstreambuf<true>::overflow(int) in main-4b77b4.o
"RInside::parseEvalQ(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-4b77b4.o
"RInside::RInside(int, char const* const*, bool, bool, bool)", referenced from:
_main in main-4b77b4.o
"RInside::~RInside()", referenced from:
_main in main-4b77b4.o
"RInside::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main-4b77b4.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 have tried what Dirk Eddelbuettel suggested, but now I receive:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/stats/libs/stats.so, 6): Symbol not found: __gfortran_pow_r8_i4
Referenced from: /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
Expected in: /Applications/MATLAB_R2013a.app/sys/os/maci64//libgfortran.2.dylib
in /Library/Frameworks/R.framework/Versions/3.0/Resources/lib/libRlapack.dylib
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
make: Nothing to be done for `rinside_sample0.cpp'.
I have seen suggestions like !unset DYLD_LIBRARY_PATH;, but I do not know how to do this in my case.
The use pattern is to
cd into the examples/standard/ directory
run make
or run make rinside_sample0 (or any other name) if you want to build just one.
You can add your own files, and make nameofthefile will build an executable.
In short, you can't just call g++ as you did.