Hi there,
I'm trying to incorporate cap'n proto into a C++ server project. It's my
first dabble with C++ so I'm struggling a bit and wondered if anyone could
offer some advice on the error below?
Many thanks,
Brent
Cmake error:
cmake -H. -Bbuild ; cmake --build build -- -j3
✗
✭ ✱
-- Configuring done
-- Generating done
-- Build files have been written to:
/Users/burt/Development/go/src/github.com/brentmurphy/piper_server/build
Scanning dependencies of target piper_server
[ 25%] Building CXX object CMakeFiles/piper_server.dir/src/main.cpp.o
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1 -triple x86_64-apple-macosx10.12.0 -Wdeprecated-objc-isa-usage
-Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name main.cpp
-mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim
-masm-verbose -munwind-tables -target-cpu penryn -target-linker-version
278.4 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file
/Users/burt/Development/go/src/github.com/brentmurphy/piper_server/build/CMakeFiles/piper_server.dir/src/main.cpp.o
-resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0
-I /usr/local/include -I
/Users/burt/Development/go/src/github.com/brentmurphy/piper -stdlib=libc++
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/Users/burt/Development/go/src/github.com/brentmurphy/piper_server/build
-ferror-limit 19 -fmessage-length 181 -stack-protector 1 -fblocks
-fobjc-runtime=macosx-10.12.0 -fencode-extended-block-signature
-fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option
-fcolor-diagnostics -o CMakeFiles/piper_server.dir/src/main.cpp.o -x c++
/Users/burt/Development/go/src/github.com/brentmurphy/piper_server/src/main.cpp
clang -cc1 version 8.1.0 (clang-802.0.42) default target
x86_64-apple-darwin16.7.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring duplicate directory "/usr/local/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/Users/burt/Development/go/src/github.com/brentmurphy/piper
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
[ 50%] Linking CXX executable ../bin/piper_server
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
-demangle -lto_library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib
-dynamic -arch x86_64 -macosx_version_min 10.12.0 -o ../bin/piper_server
-search_paths_first -headerpad_max_install_names
CMakeFiles/piper_server.dir/src/main.cpp.o
CMakeFiles/piper_server.dir/Users/burt/Development/go/src/github.com/brentmurphy/piper/piper.capnp.c++.o
CMakeFiles/piper_server.dir/Users/burt/Development/go/src/github.com/brentmurphy/piper/piper.rpc.capnp.c++.o
/usr/local/lib/libkj.a /usr/local/lib/libcapnp.a -lc++ -lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"capnp::Capability::Client::makeLocalClient(kj::Own<capnp::Capability::Server>&&)",
referenced from:
capnp::Capability::Client::Client<PiperServerImpl,
void>(kj::Own<PiperServerImpl>&&) in main.cpp.o
"capnp::Capability::Server::internalUnimplemented(char const*, char
const*, unsigned long long, unsigned short)", referenced from:
piper::rpc::Piper::Server::list(capnp::CallContext<piper::rpc::Piper::ListParams,
piper::rpc::Piper::ListResults>) in piper.rpc.capnp.c++.o
piper::rpc::Piper::Server::load(capnp::CallContext<piper::rpc::Piper::LoadParams,
piper::rpc::Piper::LoadResults>) in piper.rpc.capnp.c++.o
piper::rpc::Piper::Server::configure(capnp::CallContext<piper::rpc::Piper::ConfigureParams,
piper::rpc::Piper::ConfigureResults>) in piper.rpc.capnp.c++.o
piper::rpc::Piper::Server::process(capnp::CallContext<piper::rpc::Piper::ProcessParams,
piper::rpc::Piper::ProcessResults>) in piper.rpc.capnp.c++.o
piper::rpc::Piper::Server::finish(capnp::CallContext<piper::rpc::Piper::FinishParams,
piper::rpc::Piper::FinishResults>) in piper.rpc.capnp.c++.o
"capnp::Capability::Server::internalUnimplemented(char const*, unsigned
long long)", referenced from:
piper::rpc::Piper::Server::dispatchCall(unsigned long long, unsigned
short, capnp::CallContext<capnp::AnyPointer, capnp::AnyPointer>) in
piper.rpc.capnp.c++.o
"capnp::Capability::Server::internalUnimplemented(char const*, unsigned
long long, unsigned short)", referenced from:
piper::rpc::Piper::Server::dispatchCallInternal(unsigned short,
capnp::CallContext<capnp::AnyPointer, capnp::AnyPointer>) in
piper.rpc.capnp.c++.o
"capnp::EzRpcServer::getWaitScope()", referenced from:
_main in main.cpp.o
"capnp::EzRpcServer::EzRpcServer(capnp::Capability::Client,
kj::StringPtr, unsigned int, capnp::ReaderOptions)", referenced from:
_main in main.cpp.o
"capnp::EzRpcServer::~EzRpcServer()", referenced from:
_main in main.cpp.o
"kj::_::NeverDone::wait(kj::WaitScope&) const", 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[2]: *** [../bin/piper_server] Error 1
make[1]: *** [CMakeFiles/piper_server.dir/all] Error 2
make: *** [all] Error 2
My CMakeLists.txt file is as follows:
cmake_minimum_required(VERSION 3.9.1)
project(PiperServer)
set(PiperServer_VERSION_MAJOR 1)
set(PiperServer_VERSION_MINOR 0)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -v")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
set(DEV_DIR "/Users/burt/Development")
set(PIPER_DIR "${DEV_DIR}/go/src/github.com/brentmurphy/piper")
include_directories("/usr/local/include")
include_directories("${PIPER_DIR}")
find_library(libkj_location NAMES libkj.a)
add_library(libkj STATIC IMPORTED)
set_target_properties(libkj PROPERTIES IMPORTED_LOCATION ${libkj_location})
find_library(libcapnp_location NAMES libcapnp.a)
add_library(libcapnp STATIC IMPORTED)
set_target_properties(libcapnp PROPERTIES IMPORTED_LOCATION
${libcapnp_location})
file(GLOB SOURCES "${PIPER_DIR}/*.c++")
add_executable(piper_server ${SOURCE_DIR}/main.cpp ${SOURCES})
target_link_libraries( piper_server libkj libcapnp )
And my server code (src/main.cpp):
Enter code here#include <stdio.h>
#include <string.h>
#include <capnp/ez-rpc.h>
#include <capnp/message.h>
#include <capnp/serialize-packed.h>
#include <kj/debug.h>
#include <iostream>
#include "piper.capnp.h"
#include "piper.rpc.capnp.h"
class PiperServerImpl final: public ::piper::rpc::Piper::Server {
public:
::kj::Promise<void> list(ListContext context) override {
return NULL;
}
::kj::Promise<void> load(LoadContext context) override {
return NULL;
}
::kj::Promise<void> configure(ConfigureContext context) override {
return NULL;
}
::kj::Promise<void> process(ProcessContext context) override {
return NULL;
}
::kj::Promise<void> finish(FinishContext context) override {
return NULL;
}
private:
};
int main(int argc, const char* argv[]) {
// We expect one argument specifying the address to which
// to bind and accept connections.
if (argc != 2) {
std::cerr << "usage: " << argv[0] << " ADDRESS[:PORT]"
<< std::endl;
return 1;
}
// Set up the EzRpcServer, binding to port 5923 unless a
// different port was specified by the user. Note that the
// first parameter here can be any "Client" object or anything
// that can implicitly cast to a "Client" object. You can even
// re-export a capability imported from another server.
capnp::EzRpcServer server(kj::heap<PiperServerImpl>(), argv[1], 5923);
auto& waitScope = server.getWaitScope();
// Run forever, accepting connections and handling requests.
kj::NEVER_DONE.wait(waitScope);
KJ_LOG(ERROR, "dasdas");
}
...
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.