How to fix Veins5.2 Build Errors with Omnet++ 6.0? - omnet++

I imported Veins5.2 into Omnet++ 6.0 on Windows and when building it shows the following build Error :
Creating shared library: ../out/gcc-debug/src/libveins_dbg.dll
ld-link: error: undefined symbol: __declspec(dllimport) WSAGetLastError
referenced by ////omnetpp-6.0/omnetpp-6.0/include/omnetpp/platdep/sockets.h:33
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(sock_errno())
lld-link: error: undefined symbol: __declspec(dllimport) WSAStartup
referenced by ////omnetpp-6.0/omnetpp-6.0/include/omnetpp/platdep/sockets.h:47
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(initsocketlibonce())
referenced by ../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o
lld-link: error: undefined symbol: __declspec(dllimport) closesocket
referenced by veins/modules/mobility/traci/TraCIConnection.cc:87
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::~TraCIConnection())
referenced by veins/modules/mobility/traci/TraCIConnection.cc:127
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:152
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
lld-link: error: undefined symbol: __declspec(dllimport) inet_addr
referenced by veins/modules/mobility/traci/TraCIConnection.cc:103
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
lld-link: error: undefined symbol: __declspec(dllimport) gethostbyname
referenced by veins/modules/mobility/traci/TraCIConnection.cc:107
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
lld-link: error: undefined symbol: __declspec(dllimport) htons
referenced by veins/modules/mobility/traci/TraCIConnection.cc:119
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
lld-link: error: undefined symbol: __declspec(dllimport) socket
referenced by veins/modules/mobility/traci/TraCIConnection.cc:124
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:129
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
lld-link: error: undefined symbol: __declspec(dllimport) connect
referenced by veins/modules/mobility/traci/TraCIConnection.cc:126
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
lld-link: error: undefined symbol: __declspec(dllimport) setsockopt
referenced by veins/modules/mobility/traci/TraCIConnection.cc:147
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::connect(omnetpp::cComponent*, char const*, int))
lld-link: error: undefined symbol: __declspec(dllimport) recv
referenced by veins/modules/mobility/traci/TraCIConnection.cc:188
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::receiveMessageabi:cxx11)
referenced by veins/modules/mobility/traci/TraCIConnection.cc:210
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::receiveMessageabi:cxx11)
lld-link: error: undefined symbol: __declspec(dllimport) send
referenced by veins/modules/mobility/traci/TraCIConnection.cc:237
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::sendMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >))
referenced by veins/modules/mobility/traci/TraCIConnection.cc:253
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIConnection.o:(veins::TraCIConnection::sendMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >))
lld-link: error: undefined symbol: __declspec(dllimport) htonl
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:138
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
lld-link: error: undefined symbol: __declspec(dllimport) bindyour text
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:141
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
lld-link: error: undefined symbol: __declspec(dllimport) getsockname
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:146
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
lld-link: error: undefined symbol: __declspec(dllimport) ntohs
referenced by veins/modules/mobility/traci/TraCIScenarioManagerForker.cc:150
../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerForker.o:(veins::TraCIScenarioManagerForker::getPortNumber() const)
collect2.exe: error: ld returned 1 exit status
\\omnetpp-6.0\omnetpp-6.0\tools\win32.x86_64\mingw64\bin/llvm-ar.exe: error: unable to load '../out/gcc-debug/src/libveins_dbg.dll.a': No such file or directory
make[1]: *** [Makefile:217: ../out/gcc-debug/src/libveins_dbg.dll] Error 1
make[1]: Leaving directory '///// veins-veins-5.2/veins-veins-5.2/src'
make: *** [Makefile:36: all] Error 2
"make MODE=debug -j16 all" terminated with exit code 2. Build might be incomplete.
Build Failed. 2 errors, 2 warnings. (took 36s.395ms)
Cleaned local , cleane build, still has the same issue

I had build errors also when trying to get Veins running with OMNet++ 6.0 on Windows. See the changelog here: http://veins.car2x.org/download/. Veins lists recommended versions and recommends OMNet++ 5.6.2 instead of 6.0. I had no build errors when using the recommended versions. Good luck!

Related

how to build grpc to static link library on macOS

I want to build grpc to static link library on macOS,my macOS system is macOS Monterey version 12.6(Intel chip).
I found https://chromium.googlesource.com/external/github.com/grpc/grpc/+/HEAD/BUILDING.md#building-with-cmake build shared libraries that is Dynamic-link library,but I want to get static-link library.
gcc version is
mindgood#minds-MacBook-Pro lib % gcc --version
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
mindgood#minds-MacBook-Pro lib %
My ~/.zshrc config is
export ANDROID_HOME=/Users/mindgood/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export ANDROID_NDK=/Users/mindgood/Library/Android/sdk/ndk/25.1.8937393
export PATH="/usr/local/opt/openssl#3/bin:$PATH"
export CPATH=/usr/local/opt/openssl#3/include:"${CPATH}"
export PKG_CONFIG_PATH=/usr/local/opt/openssl#3/lib/pkgconfig:"${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH=/usr/local/opt/openssl#3/lib:"${LD_LIBRARY_PATH}"
I have installed openssl.
mindgood#minds-MacBook-Pro ~ % openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
mindgood#minds-MacBook-Pro ~ % whereis opnessl
opnessl:
mindgood#minds-MacBook-Pro ~ % find / -name 'openssl'
/usr/bin/openssl
find: /usr/sbin/authserver: Permission denied
/usr/local/bin/openssl
/usr/local/include/openssl
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/openssl
/usr/local/opt/openssl
/usr/local/Cellar/openssl#3/3.0.5/bin/openssl
/usr/local/Cellar/openssl#3/3.0.5/include/openssl
/usr/local/Cellar/openssl#3/3.0.5/share/doc/openssl
/usr/local/share/doc/openssl
find: /Library/Application Support/Apple/ParentalControls/Users: Permission denied
find: /Library/Application Support/Apple/AssetCache/Data: Permission denied
find: /Library/Application Support/ApplePushService: Permission denied
find: /Library/Application Support/com.apple.TCC: Operation not permitted
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/openssl
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/openssl
^C
mindgood#minds-MacBook-Pro ~ %
mindgood#minds-MacBook-Pro ~ % cd /usr/local/lib
mindgood#minds-MacBook-Pro lib % ls
engines-1.1 libcrypto.3.dylib libcrypto.dylib libssl.3.dylib libssl.dylib
libcrypto.1.1.dylib libcrypto.a libssl.1.1.dylib libssl.a pkgconfig
mindgood#minds-MacBook-Pro lib %
then I use below command:
git clone --recurse-submodules -b v1.30.0 https://github.com/grpc/grpc
cd grpc
git checkout -b v1.22.x remotes/origin/v1.22.x
cmake ../grpc -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DgRPC_BUILD_CODEGEN=OFF -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-26 -DCMAKE_BUILD_TYPE=Release
cmake --build .
When I build grpc to static link library,An error occurs when the progress reaches 91%:
mindgood#minds-MacBook-Pro grpc % cmake --build .
Consolidate compiler generated dependencies of target address_sorting
[ 0%] Built target address_sorting
Consolidate compiler generated dependencies of target gpr
[ 2%] Built target gpr
Consolidate compiler generated dependencies of target c-ares
[ 5%] Built target c-ares
Consolidate compiler generated dependencies of target zlibstatic
[ 6%] Built target zlibstatic
Consolidate compiler generated dependencies of target grpc
[ 26%] Built target grpc
Consolidate compiler generated dependencies of target grpc_cronet
[ 44%] Built target grpc_cronet
Consolidate compiler generated dependencies of target grpc_unsecure
[ 59%] Built target grpc_unsecure
Consolidate compiler generated dependencies of target libprotobuf
[ 64%] Built target libprotobuf
Consolidate compiler generated dependencies of target grpc++
[ 67%] Built target grpc++
Consolidate compiler generated dependencies of target grpc++_cronet
[ 83%] Built target grpc++_cronet
Consolidate compiler generated dependencies of target grpc++_unsecure
[ 85%] Built target grpc++_unsecure
Consolidate compiler generated dependencies of target libprotoc
[ 90%] Built target libprotoc
Consolidate compiler generated dependencies of target grpc_plugin_support
[ 91%] Built target grpc_plugin_support
Consolidate compiler generated dependencies of target grpc_csharp_ext
[ 91%] Linking CXX shared library libgrpc_csharp_ext.so
ld: error: undefined symbol: X509_STORE_new
>>> referenced by ssl_transport_security.cc:787 (src/core/tsi/ssl_transport_security.cc:787)
>>> ssl_transport_security.cc.o:(tsi_ssl_root_certs_store_create(char const*)) in archive libgrpc.a
ld: error: undefined symbol: X509_STORE_free
>>> referenced by ssl_transport_security.cc:797 (src/core/tsi/ssl_transport_security.cc:797)
>>> ssl_transport_security.cc.o:(tsi_ssl_root_certs_store_create(char const*)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:806 (src/core/tsi/ssl_transport_security.cc:806)
>>> ssl_transport_security.cc.o:(tsi_ssl_root_certs_store_destroy(tsi_ssl_root_certs_store*)) in archive libgrpc.a
ld: error: undefined symbol: BIO_new_mem_buf
>>> referenced by ssl_transport_security.cc:593 (src/core/tsi/ssl_transport_security.cc:593)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:519 (src/core/tsi/ssl_transport_security.cc:519)
>>> ssl_transport_security.cc.o:(populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:563 (src/core/tsi/ssl_transport_security.cc:563)
>>> ssl_transport_security.cc.o:(populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*)) in archive libgrpc.a
>>> referenced 1 more times
ld: error: undefined symbol: OPENSSL_sk_new_null
>>> referenced by x509.h:77 (/usr/local/opt/openssl#3/include/openssl/x509.h:77)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
ld: error: undefined symbol: PEM_read_bio_X509_AUX
>>> referenced by ssl_transport_security.cc:602 (src/core/tsi/ssl_transport_security.cc:602)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:602 (src/core/tsi/ssl_transport_security.cc:602)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:602 (src/core/tsi/ssl_transport_security.cc:602)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced 2 more times
ld: error: undefined symbol: X509_free
>>> referenced by ssl_transport_security.cc:632 (src/core/tsi/ssl_transport_security.cc:632)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:632 (src/core/tsi/ssl_transport_security.cc:632)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:641 (src/core/tsi/ssl_transport_security.cc:641)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced 4 more times
ld: error: undefined symbol: X509_get_subject_name
>>> referenced by ssl_transport_security.cc:608 (src/core/tsi/ssl_transport_security.cc:608)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:266 (src/core/tsi/ssl_transport_security.cc:266)
>>> ssl_transport_security.cc.o:(peer_from_x509(x509_st*, int, tsi_peer*)) in archive libgrpc.a
ld: error: undefined symbol: X509_NAME_dup
>>> referenced by ssl_transport_security.cc:614 (src/core/tsi/ssl_transport_security.cc:614)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
ld: error: undefined symbol: OPENSSL_sk_push
>>> referenced by x509.h:77 (/usr/local/opt/openssl#3/include/openssl/x509.h:77)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
ld: error: undefined symbol: ERR_clear_error
>>> referenced by ssl_transport_security.cc:622 (src/core/tsi/ssl_transport_security.cc:622)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:622 (src/core/tsi/ssl_transport_security.cc:622)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:604 (src/core/tsi/ssl_transport_security.cc:604)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced 2 more times
ld: error: undefined symbol: X509_STORE_add_cert
>>> referenced by ssl_transport_security.cc:623 (src/core/tsi/ssl_transport_security.cc:623)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:623 (src/core/tsi/ssl_transport_security.cc:623)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
ld: error: undefined symbol: ERR_get_error
>>> referenced by ssl_transport_security.cc:624 (src/core/tsi/ssl_transport_security.cc:624)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:624 (src/core/tsi/ssl_transport_security.cc:624)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:1237 (src/core/tsi/ssl_transport_security.cc:1237)
>>> ssl_transport_security.cc.o:(ssl_handshaker_next(tsi_handshaker*, unsigned char const*, unsigned int, unsigned char const**, unsigned int*, tsi_handshaker_result**, void (*)(tsi_result, void*, unsigned char const*, unsigned int, tsi_handshaker_result*), void*)) in archive libgrpc.a
>>> referenced 2 more times
ld: error: undefined symbol: OPENSSL_sk_pop_free
>>> referenced by x509.h:77 (/usr/local/opt/openssl#3/include/openssl/x509.h:77)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by x509v3.h:166 (/usr/local/opt/openssl#3/include/openssl/x509v3.h:166)
>>> ssl_transport_security.cc.o:(peer_from_x509(x509_st*, int, tsi_peer*)) in archive libgrpc.a
ld: error: undefined symbol: BIO_free
>>> referenced by ssl_transport_security.cc:648 (src/core/tsi/ssl_transport_security.cc:648)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:0 (src/core/tsi/ssl_transport_security.cc:0)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
>>> referenced by ssl_transport_security.cc:552 (src/core/tsi/ssl_transport_security.cc:552)
>>> ssl_transport_security.cc.o:(populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*)) in archive libgrpc.a
>>> referenced 10 more times
ld: error: undefined symbol: X509_NAME_free
>>> referenced by ssl_transport_security.cc:0 (src/core/tsi/ssl_transport_security.cc:0)
>>> ssl_transport_security.cc.o:(x509_store_load_certs(x509_store_st*, char const*, unsigned int, stack_st_X509_NAME**)) in archive libgrpc.a
ld: error: undefined symbol: SSL_new
>>> referenced by ssl_transport_security.cc:1340 (src/core/tsi/ssl_transport_security.cc:1340)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
ld: error: undefined symbol: SSL_set_info_callback
>>> referenced by ssl_transport_security.cc:1352 (src/core/tsi/ssl_transport_security.cc:1352)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
ld: error: undefined symbol: BIO_new_bio_pair
>>> referenced by ssl_transport_security.cc:1354 (src/core/tsi/ssl_transport_security.cc:1354)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
ld: error: undefined symbol: SSL_set_bio
>>> referenced by ssl_transport_security.cc:1359 (src/core/tsi/ssl_transport_security.cc:1359)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
ld: error: undefined symbol: SSL_set_connect_state
>>> referenced by ssl_transport_security.cc:1362 (src/core/tsi/ssl_transport_security.cc:1362)
>>> ssl_transport_security.cc.o:(create_tsi_ssl_handshaker(ssl_ctx_st*, int, char const*, tsi_ssl_handshaker_factory*, tsi_handshaker**)) in archive libgrpc.a
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libgrpc_csharp_ext.so] Error 1
make[1]: *** [CMakeFiles/grpc_csharp_ext.dir/all] Error 2
make: *** [all] Error 2
mindgood#minds-MacBook-Pro grpc %
How to solve this error? Please help me. Or how to compile grpc to static link library on macOS?
Thanks in advance.
This problem solved by myself,the answer is at https://github.com/android/ndk/issues/1789

no valid method for accessing or setting values in protobuf class

I have been struggling with Google protobufs lately. I have written a proto file called Button.proto.
Here are its contents:
syntax = "proto3";
package robotjoystick;
message Button {
string name = 1;
int32 id = 2;
uint32 state = 3;
}
I successfully compiled it with this command (with the $USER replaced with the acctual computer user):
protoc -I=/home/$USER/robotjoystickserver --cpp_out=/home/$USER/robotjoystickserver/proto_classes Button.proto
I am using protobuf version 3.7.1.
My *.cpp file is calleddumbprrotos.cpp and it is not compiling for some reason.
Here is my *.cpp file:
// Client side C/C++ program to demonstrate Socket programming
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
// This line was forgotten apparently - https://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found
#include <arpa/inet.h>
// This one was also forgotten - https://www.reddit.com/r/learnprogramming/comments/3tlii5/clinux_why_is_write_or_close_not_declared_in_this/
#include <unistd.h>
// This is SDL 2.0, the joystick control library
#include <SDL2/SDL.h>
// For Ctrl+C quitting
#include <signal.h>
// for std::end
//#include <iostream>
// Now we import the header files the protobuf compiler generated.
#include "proto_classes/Button.pb.h"
// This is a standard port
#define PORT 8080
//#include<iostream>
using namespace std;
// For the protobuf generated class.
using namespace robotjoystick;
int main(int argc, char const *argv[])
{
// https://developers.google.com/protocol-buffers/docs/cpptutorial
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
GOOGLE_PROTOBUF_VERIFY_VERSION;
// Broken method 1
/*
const string thename = "blah";
robotjoystick::Button * thebutton;
thebutton = new Button();
thebutton->set_name("john");
thebutton->set_id(12);
*/
// Broken method 2
const string thename = "blah";
robotjoystick::Button thebutton;
thebutton.set_name("john");
thebutton.set_id(12);
return 0;
}
The 2 sections of code I have labeled are 2 versions of the same thing that I am trying to accomplish, but both are throwing the same type of error and I have no idea how to interpret it. What do I need to do to make this code compile?
I should also mention that I installed protobuf 3.7.1 right off of my home directory (meaning that the zip file for protobuf was extracted there and then installed there).
The error I get when I currently run the code, the exact way it is, I get this error:
Compiling dumbprotos.cpp
/tmp/cc7HHVQf.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
dumbprotos.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x5): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/tmp/ccMdby3z.o: In function `AddDescriptors_Button_2eproto()':
Button.pb.cc:(.text+0xa6): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable*, void (* const*)(), int)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
Button.pb.cc:(.text+0x660): undefined reference to `google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)'
Button.pb.cc:(.text+0x73f): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const':
Button.pb.cc:(.text+0x904): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::InternalSerializeWithCachedSizesToArray(unsigned char*) const':
Button.pb.cc:(.text+0xa98): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button::GetMetadata() const':
Button.pb.cc:(.text+0x1386): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::AssignDescriptorsTable*)'
/tmp/ccMdby3z.o: In function `robotjoystick::Button* google::protobuf::Arena::CreateMaybeMessage<robotjoystick::Button>(google::protobuf::Arena*)':
Button.pb.cc:(.text+0x142e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text+0x144b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o: In function `google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int*)':
Button.pb.cc:(.text._ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj[_ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj]+0x78): undefined reference to `google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)'
/tmp/ccMdby3z.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
Button.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x23e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x25b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x14): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x19): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InternalMetadataWithArena::default_instance()':
Button.pb.cc:(.text._ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv[_ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv]+0x5): undefined reference to `google::protobuf::UnknownFieldSet::default_instance()'
/tmp/ccMdby3z.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15c): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x176): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccMdby3z.o:(.rodata._ZTVN13robotjoystick6ButtonE[_ZTVN13robotjoystick6ButtonE]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
When I compile the code wth the other broken scenario,
const string thename = "blah";
robotjoystick::Button * thebutton;
thebutton = new Button();
thebutton->set_name("john");
thebutton->set_id(12);
I get this error instead:
Compiling dumbprotos.cpp
/tmp/ccaCT7Iy.o: In function `google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()':
dumbprotos.cpp:(.text._ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev[_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedB5cxx11Ev]+0x5): undefined reference to `google::protobuf::internal::fixed_address_empty_string[abi:cxx11]'
/tmp/ccfmvBXP.o: In function `AddDescriptors_Button_2eproto()':
Button.pb.cc:(.text+0xa6): undefined reference to `google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable*, void (* const*)(), int)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*)':
Button.pb.cc:(.text+0x660): undefined reference to `google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)'
Button.pb.cc:(.text+0x73f): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const':
Button.pb.cc:(.text+0x904): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::InternalSerializeWithCachedSizesToArray(unsigned char*) const':
Button.pb.cc:(.text+0xa98): undefined reference to `google::protobuf::internal::WireFormatLite::VerifyUtf8String(char const*, int, google::protobuf::internal::WireFormatLite::Operation, char const*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button::GetMetadata() const':
Button.pb.cc:(.text+0x1386): undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::AssignDescriptorsTable*)'
/tmp/ccfmvBXP.o: In function `robotjoystick::Button* google::protobuf::Arena::CreateMaybeMessage<robotjoystick::Button>(google::protobuf::Arena*)':
Button.pb.cc:(.text+0x142e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text+0x144b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o: In function `google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int*)':
Button.pb.cc:(.text._ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj[_ZN6google8protobuf2io16CodedInputStream12ReadVarint32EPj]+0x78): undefined reference to `google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)'
/tmp/ccfmvBXP.o: In function `google::protobuf::Arena::AllocHook(std::type_info const*, unsigned long) const':
Button.pb.cc:(.text._ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom[_ZNK6google8protobuf5Arena9AllocHookEPKSt9type_infom]+0x3d): undefined reference to `google::protobuf::Arena::OnArenaAllocation(std::type_info const*, unsigned long) const'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::ArenaStringPtr::CreateInstance(google::protobuf::Arena*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x23e): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN6google8protobuf8internal14ArenaStringPtr14CreateInstanceEPNS0_5ArenaEPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x25b): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InitSCC(google::protobuf::internal::SCCInfoBase*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE[_ZN6google8protobuf8internal7InitSCCEPNS1_11SCCInfoBaseE]+0x4d): undefined reference to `google::protobuf::internal::InitSCCImpl(google::protobuf::internal::SCCInfoBase*)'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::OnShutdownDestroyMessage(void const*)':
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x14): undefined reference to `google::protobuf::internal::DestroyMessage(void const*)'
Button.pb.cc:(.text._ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv[_ZN6google8protobuf8internal24OnShutdownDestroyMessageEPKv]+0x19): undefined reference to `google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*)'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InternalMetadataWithArena::default_instance()':
Button.pb.cc:(.text._ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv[_ZN6google8protobuf8internal25InternalMetadataWithArena16default_instanceEv]+0x5): undefined reference to `google::protobuf::UnknownFieldSet::default_instance()'
/tmp/ccfmvBXP.o: In function `google::protobuf::internal::InternalMetadataWithArenaBase<google::protobuf::UnknownFieldSet, google::protobuf::internal::InternalMetadataWithArena>::mutable_unknown_fields_slow()':
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x15c): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned long)'
Button.pb.cc:(.text._ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv[_ZN6google8protobuf8internal29InternalMetadataWithArenaBaseINS0_15UnknownFieldSetENS1_25InternalMetadataWithArenaEE27mutable_unknown_fields_slowEv]+0x176): undefined reference to `google::protobuf::internal::ArenaImpl::AllocateAlignedAndAddCleanup(unsigned long, void (*)(void*))'
/tmp/ccfmvBXP.o:(.rodata._ZTVN13robotjoystick6ButtonE[_ZTVN13robotjoystick6ButtonE]+0xb8): undefined reference to `google::protobuf::Message::SpaceUsedLong() const'
collect2: error: ld returned 1 exit status
This is the script I am using to compile the code:
#!/bin/sh
echo "Compiling dumbprotos.cpp"
echo ""
g++ dumbprotos.cpp proto_classes/Button.pb.cc -o ./pleasework -std=c++11 -lSDL2 -lprotobuf
I think that is everything I need to show you guys. Did I miss anything? What do I need to do to make my *.cpp code compile?
I am on Ubuntu 16.04.
After thinking about the comment provided by #goduk, I thought I should look further into the linking library issue and find the files I need to source. It turns out that I was not linking to any specific location.
I decided to look through the docs under protobuf-3.7.1/src/README.md to explore further to find the .../lib/ directory. After re-reading those docs, a specific section caught my eye.
To compile a package that uses Protocol Buffers, you need to pass
various flags to your compiler and linker. As of version 2.2.0,
Protocol Buffers integrates with pkg-config to manage this. If you
have pkg-config installed, then you can invoke it to get a list of
flags like so:
pkg-config --cflags protobuf # print compiler flags
pkg-config --libs protobuf # print linker flags
pkg-config --cflags --libs protobuf # print both
For example:
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
On my laptop, the command pkg-config --cflags --libs protobuf returns -pthread -I/usr/local/include -L/usr/local/lib -lprotobuf -pthread.
Instead of trying to determine the correct compiling flags, I simply needed to call the required flags using pkg-config --cflags --libs protobuf at the end.
I had never heard of pkg-config before, but this solved all of my problems.
The final bash script line is now this:
g++ dumbprotos.cpp proto_classes/Button.pb.cc -o ./pleasework -std=c++11 -lSDL2 `pkg-config --cflags --libs protobuf`
Thanks for the help.
(This is a linker type issue.)
I should also mention that, if the protobuf object contains other protobuf objects, you have to include those in the command line call:
g++ my_program.cc my_proto_imported.pb.cc my_proto_containing.pb.cc `pkg-config --cflags --libs protobuf`
Meaning that my_proto_imported.pb.cc is a protobuf imported and used in my_proto_contained.pb.cc.

Undefined References to boost while making uhd in Ubuntu 16.04

My first attempt to build uhd was to use a script I had written that had worked in the past on two laptops running 14.04. After that, I went back here:
http://files.ettus.com/manual/page_build_guide.html#build_instructions_unix
After that, I went here:
https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux
I get the following compile errors. I'm at a loss, as I have install all of libboost, so I'm not sure what is missing. I'm building on the maint branch. I am on a new computer running 16.04.
[ 61%] Built target uhd
[ 61%] Linking CXX executable sync_to_gps
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `_main(int, char**)':
sync_to_gps.cpp:(.text+0x6de): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const':
sync_to_gps.cpp:(.text._ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE[_ZNK5boost15program_options11typed_valueISscE6xparseERNS_3anyERKSt6vectorISsSaISsEE]+0x1f): undefined reference to `boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `std::vector<std::string, std::allocator<std::string> > boost::program_options::to_internal<std::string>(std::vector<std::string, std::allocator<std::string> > const&)':
sync_to_gps.cpp:(.text._ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE[_ZN5boost15program_options11to_internalISsEESt6vectorISsSaISsEERKS2_IT_SaIS5_EE]+0x7d): undefined reference to `boost::program_options::to_internal(std::string const&)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::basic_parsed_options<char> boost::program_options::parse_command_line<char>(int, char const* const*, boost::program_options::options_description const&, int, boost::function1<std::pair<std::string, std::string>, std::string const&>)':
sync_to_gps.cpp:(.text._ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE[_ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE]+0x15e): undefined reference to `boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)'
sync_to_gps.cpp:(.text._ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE[_ZN5boost15program_options18parse_command_lineIcEENS0_20basic_parsed_optionsIT_EEiPKPKS3_RKNS0_19options_descriptionEiNS_9function1ISt4pairISsSsERKSsEE]+0x1ef): undefined reference to `boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>)'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o: In function `boost::program_options::typed_value<std::string, char>::name() const':
sync_to_gps.cpp:(.text._ZNK5boost15program_options11typed_valueISscE4nameEv[_ZNK5boost15program_options11typed_valueISscE4nameEv]+0x29): undefined reference to `boost::program_options::arg'
CMakeFiles/sync_to_gps.dir/sync_to_gps.cpp.o:(.rodata._ZTVN5boost15program_options11typed_valueISscEE[_ZTVN5boost15program_options11typed_valueISscEE]+0x38): undefined reference to `boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const'
../lib/libuhd.so.003.010: undefined reference to `boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::load(std::string&)'
../lib/libuhd.so.003.010: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > > const&)'
../lib/libuhd.so.003.010: undefined reference to `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&)'
../lib/libuhd.so.003.010: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
../lib/libuhd.so.003.010: undefined reference to `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::string const&)'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/sync_to_gps.dir/build.make:107: recipe for target 'examples/sync_to_gps' failed
make[2]: *** [examples/sync_to_gps] Error 1
CMakeFiles/Makefile2:393: recipe for target 'examples/CMakeFiles/sync_to_gps.dir/all' failed
make[1]: *** [examples/CMakeFiles/sync_to_gps.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I had a similar issue which turned out to be an older version of GCC still installed on my Ubuntu system being called. Look at /usr/bin/gcc and /usr/bin/g++ and see if they're linked to /usr/bin/gcc-5 and /usr/bin/g++-5 respectively.

compiling litecoin OSX 10.9.1

I'm trying to compile the Litecoin source (https://github.com/litecoin-project/litecoin.git). Doing this in windows with VmWare OSX 10.9.1(64bit).
I cloned it and in terminal ran:
make -f makefile.osx USE_UPNP=-
It spits out this error:
Undefined symbols for architecture x86_64:
"boost::program_options::to_internal(std::string const&)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::getline(std::string&) in util.o
"boost::program_options::detail::common_config_file_iterator::common_config_file_iterator(std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool)", referenced from:
boost::program_options::detail::basic_config_file_iterator<char>::basic_config_file_iterator(std::istream&, std::set<std::string, std::less<std::string>, std::allocator<std::string> > const&, bool) in util.o
"Db::verify(char const*, char const*, std::ostream*, unsigned int)", referenced from:
CDBEnv::Verify(std::string, bool (*)(CDBEnv&, std::string)) in db.o
CDBEnv::Salvage(std::string, bool, std::vector<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > >, std::allocator<std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, std::vector<unsigned char, std::allocator<unsigned char> > > > >&) in db.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: *** [litecoind] Error 1
I've been googling like crazy but can't seem to find a proper solution.

A language engine with no standard library

Does anyone know of a language engine (compiler or interpreter, AST, syntax, and basic semantics) but with NO standard library (hopefully not even integers or arithmetic). Is there such a thing? I'd want to be able to implement the standard library in C++. Does such a thing exist?
GCC (and I'm pretty sure a lot of other compilers) lets you build your code without the standard headers and/or libraries, with the -nostdinc (also -nostdinc++ for C++) and -nostdlib flags.
For example:
$ cat t.cpp
#include <iostream>
int main()
{
std::cout << "ouch" << std::endl;
}
$ g++ -nostdinc t.cpp # Failed compilation
t.cpp:1:20: error: no include path in which to search for iostream
t.cpp: In function ‘int main()’:
t.cpp:5:5: error: ‘cout’ is not a member of ‘std’
t.cpp:5:28: error: ‘endl’ is not a member of ‘std’
$ g++ -nostdinc++ t.cpp # Failed compilation
t.cpp:1:20: fatal error: iostream: No such file or directory
compilation terminated.
$ g++ -nostdlib t.cpp # Compiles, but fails to link
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400158
/tmp/ccPPO3l6.o: In function `main':
t.cpp:(.text+0xa): undefined reference to `std::cout'
t.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
t.cpp:(.text+0x14): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
t.cpp:(.text+0x1c): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccPPO3l6.o: In function `__static_initialization_and_destruction_0(int, int)':
t.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'
t.cpp:(.text+0x4f): undefined reference to `std::ios_base::Init::~Init()'
t.cpp:(.text+0x54): undefined reference to `__dso_handle'
t.cpp:(.text+0x61): undefined reference to `__cxa_atexit'
collect2: ld returned 1 exit status
This is used for building things like kernel code that can't use the C library.
Good luck with implementing a standard library, that's an enormous task.

Resources