Linker Error to libPocoJSON.a

Please post support and help requests here.
grimwm
Posts: 1
Joined: 14 Sep 2017, 06:24

Linker Error to libPocoJSON.a

Postby grimwm » 14 Sep 2017, 06:40

Hi, I've just started using Poco, beginning with just starting to use conan. I'm currently in a pickle trying to solve a linker error that keeps coming up, and it's only happening (so far) when trying to use the JSON libraries. I have another target in my cmake build that uses Poco timer libraries without issue.

Can anyone please tell me how to fix this linker error? It's driving me nuts.

I'll skip the conan details and just say that I'm compiling with c++11 and trying to link the same as well. As far as I know from the conan output, the Poco library is built using c++11.

First, my linker error:

Code: Select all

Classifier.cpp:(.text.startup+0x120): undefined reference to `Poco::JSON::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'


Then, the build and link output (with build and link commands):

Code: Select all

[ 75%] Building CXX object CMakeFiles/classifier.dir/Classifier.cpp.o
/usr/bin/c++   -I/home/wgrim/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/adc07af7ea8a81a3f68fa3f033d07d429a48706f/include -I/home/wgrim/.conan/data/OpenSSL/1.0.2l/conan/stable/package/93a39911b86ec3005dfe8be5be3b85a2792590e2/include -I/home/wgrim/.conan/data/zlib/1.2.11/conan/stable/package/500a5737cfb7bee13d4a0039e72446892ca242ab/include  -O3 -DNDEBUG    -std=c++11 -DPOCO_STATIC=ON -DPOCO_NO_AUTOMATIC_LIBS -o CMakeFiles/classifier.dir/Classifier.cpp.o -c /home/wgrim/tmp/Classifier.cpp
[100%] Linking CXX executable bin/classifier
/home/wgrim/.idea/clion-2017.2.2/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/classifier.dir/link.txt --verbose=1
/usr/bin/c++     -O3 -DNDEBUG        -rdynamic CMakeFiles/classifier.dir/Classifier.cpp.o  -o bin/classifier  -L/home/wgrim/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/adc07af7ea8a81a3f68fa3f033d07d429a48706f/lib  -L/home/wgrim/.conan/data/OpenSSL/1.0.2l/conan/stable/package/93a39911b86ec3005dfe8be5be3b85a2792590e2/lib  -L/home/wgrim/.conan/data/zlib/1.2.11/conan/stable/package/500a5737cfb7bee13d4a0039e72446892ca242ab/lib -Wl,-rpath,/home/wgrim/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/adc07af7ea8a81a3f68fa3f033d07d429a48706f/lib:/home/wgrim/.conan/data/OpenSSL/1.0.2l/conan/stable/package/93a39911b86ec3005dfe8be5be3b85a2792590e2/lib:/home/wgrim/.conan/data/zlib/1.2.11/conan/stable/package/500a5737cfb7bee13d4a0039e72446892ca242ab/lib -lPocoUtil -lPocoMongoDB -lPocoNet -lPocoNetSSL -lPocoCrypto -lPocoData -lPocoDataSQLite -lPocoZip -lPocoXML -lPocoJSON -lPocoFoundation -lpthread -lrt -lssl -lcrypto -ldl -lz
CMakeFiles/classifier.dir/Classifier.cpp.o: In function `main':
Classifier.cpp:(.text.startup+0x120): undefined reference to `Poco::JSON::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/classifier.dir/build.make:94: recipe for target 'bin/classifier' failed
make[2]: *** [bin/classifier] Error 1
make[2]: Leaving directory '/home/wgrim/tmp/cmake-build-release'
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/classifier.dir/all' failed
make[1]: *** [CMakeFiles/classifier.dir/all] Error 2
make[1]: Leaving directory '/home/wgrim/tmp/cmake-build-release'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


Then a PARTIAL objdump of libPocoJSONd.a, filtered through c++filt:

Code: Select all

$ objdump -xt /home/wgrim/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/adc07af7ea8a81a3f68fa3f033d07d429a48706f/lib/libPocoJSON.a | c++filt | grep Poco::JSON::Parser::parse
0000000000000990 g     F .text   0000000000000136 Poco::JSON::Parser::parseBufferPopBackChar()
0000000000000ad0 g     F .text   000000000000021b Poco::JSON::Parser::parseBufferPushBackChar(char)
0000000000001990 g     F .text   00000000000008a1 Poco::JSON::Parser::parseBuffer()
0000000000002240 g     F .text   0000000000001310 Poco::JSON::Parser::parse(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
0000000000000000  w    F .text._ZN4Poco4JSON6Parser9parseCharINS1_6SourceISt19istreambuf_iteratorIcSt11char_traitsIcEEEEEEbiRT_   0000000000001098 bool Poco::JSON::Parser::parseChar<Poco::JSON::Parser::Source<std::istreambuf_iterator<char, std::char_traits<char> > > >(int, Poco::JSON::Parser::Source<std::istreambuf_iterator<char, std::char_traits<char> > >&)
0000000000003550 g     F .text   0000000000000394 Poco::JSON::Parser::parse(std::basic_istream<char, std::char_traits<char> >&)


And finally, my actual code:

Code: Select all

#include <sstream>
#include <fstream>

#include "Poco/JSON/Parser.h"

int main(int argc, char* argv[]) {
    Poco::JSON::Parser parser;

    std::ifstream ifs(argv[1]);
    std::string line;
    while (std::getline(ifs, line)) {
        Poco::Dynamic::Var var = parser.parse(line);
    }

    return 0;
}

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest

cron