qtcreator issue compiling with protobuff - protocol-buffers

Im trying to compile my code with a new version of protobuf (currently it was compiled with custom version, and i would like to compile it with the version that comes with the ubuntu via apt-get)
in the project settings i'v added -lprotobuf
.obj/Test.pb.o: In function `test_ns::protobuf_AssignDesc_Test_2eproto()':
<<path to file>>/Test.pb.cc:115: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
the line with the error('Test.pb.cc'):
void protobuf_AssignDesc_Test_2eproto() {
protobuf_AddDesc_Test_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"Test.proto");
i can see that the error caused when trying to locate the file "Test.proto", but it exist in another directory, and it was used by the protoc command to generate Test.pb.cc and Test.pb.h files

Just fund the reason, the protobuff provided by the ubuntu compiled with different ABI, matching the ABI in our project fixed the issue

Related

Bazel failed to include a external static library .a

-- Question solved --
This question is solved. Thanks for all the help!
The problem and the reason is briefly stated as following for other readers in the future:
[Environment]
Ubuntu 14.04, Bazel, C++
[Question]
I want to include an external library. So I download the source file and make it as as a static lib .a.
I correctly set the BUILD, WORKSPACE and related files. However, when compile, it alerts the error:
Linking of rule '//main' failed (Exit 1)
main: error: undefined reference to 'void ex_lib::compute(double*, double const*, double const*)'
collect2: error: ld returned 1 exit status
I tried with the .lo and alwayslink method here but doesn't work.
Alternate to "`--whole-archive`" in bazel
[Reason]
It is because that the external library source files contains duplicate header files. So I fix the header file problem. Make the .a again. Then everything works.
So nothing wrong with the bazel. It is the library itself that cause the problem. But the error information is confusing and I think it is caused by bazel.
What you can do to investigate further is to run the clean bazel build with --subcommands to see individual command lines of actions executed. Then you can cd into the sandbox, and execute the same gcc command as bazel does and debug what's wrong. Or you can try to get linking to work by handwriting gcc command, and pasting here both the command bazel generated, and your desired command. Is it possible that you have multiple liegroups libs installed on the system and gcc is getting one that's incompatible with headers you're including?
The problem is solved. Special thanks to mhlopko.
It is mainly because there is errors with the lib source file. Thus .a file I use contains errors. Now the bazel works fine with the new lib file.
By the way, now bazel works fine with both .a or .so file that I generated.

Error in compiling caffe on Ubuntu 17.04

I need to use the Single Shot Multibox Detector implemented in Caffe. After cloning the repository, I've switched to the correct branch and I've installed all the dependencies required (by following the guide on caffe website). Unfortunately, when I compile at certain point I get this error:
.build_release/lib/libcaffe.so: undefined reference to "boost::re_detail_106200::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const"
But boost is installed. How can I resolve?
Add boost_regex to LIBRARIES variable in Makefile in case you use Makefile.config compilation, or to find_package(Boost 1.54 REQUIRED COMPONENTS system thread filesystem) line in caffe/cmake/Dependencies.cmake

linking std::experimental::filesystem with Xcode 9

I am using std::experimental::filesystem with Xcode 9.0 beta. The compiler phase completes OK but the linker complains of undefined symbols:
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__filename() const
std::experimental::filesystem::v1::path::__stem() const
std::experimental::filesystem::v1::__status(std::experimental::filesystem::v1::path const&, std::__1::error_code*)
I am also using std::experimental::filesystem::canonical(), but the linker isn't complaining about that being missing.
How can I configure the project to include these missing references?
UPDATE:
I have been experimenting with a simpler program. If I just use canonical() then the linker complains that it is missing.
I can use std::experimental::optional - everything compiles, links and runs OK. But 'optional' is a template and so probably doesn't involve a library.
Are you compiling with any -std= option ("C++ Language Dialect" option in Xcode)?

How can I fix this build error when building Qt 5.7 statically with MinGW?

When I tried to compile Qt 5.7 statically in order to get a standalone application for windows deployment with all dependencies as mentionned here i got the following errors:
C:\Qt\Qt5.7.0\5.7\Src\qtbase/qmake/library/qmakebuiltins.cpp: In member function 'QByteArray QMakeEvaluator::getCommandOutput(const QString&) const'
C:\Qt\Qt5.7.0\5.7\Src\qtbase/qmake/library/qmakebuiltins.cpp:419:94: error: '_popen' was not declared in this scope
+ QLatin1String(" && ") + args).toLocal8Bit().constData(), "r")) {
C:\Qt\Qt5.7.0\5.7\Src\qtbase/qmake/library/qmakebuiltins.cpp:427:23: error: '_pclose' was not declared in this scope
QT_PCLOSE(proc);
Makefile:204: recipe for target 'qmakebuiltins.o' failed
mingw32-make: *** [qmakebuiltins.o] Error 1
Building qmake failed, return code 2
My aim is to make the final release standalone and size optimized (only ncessary symbols that being used from the libs), also in the link i provided i don't see MinGw mentionned, I don't have nmake (and don't want to get it).
It's open source. All of our recipes and patches are released. MSYS2 has a track record of not being abandonware, but if you find places we can do better then please help out. MSYS2 is highly compatible .. with the rest of MSYS2. We can't promise more than that.

OpenCV undefined error in Xcode

I am working on an OpenCV-based project on Xcode 5.02, OS X 10.9.
My OpenCV was installed using homebrew.
I get the following error
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)"
I have added Header Search Paths /usr/local/include nonrecursive and /usr/local/include/opencv2 nonrecursive;
I have added Library Search Paths /usr/local/lib;
I have added all .dylib file under /usr/local/Cellar/opencv/2.4.3/lib to the project.
From what I can see, you are trying to run an Objective-C++ project, right? I presume that because cv::nameWindow is a c++ function of OpenCV.
You can have a look on this question, where I had a similar issue and solved it configuring the project properly.
This error means your XCode project is not finding the cv::namedWindow function. Are u sure OpenCV is properly installed in your PC? Can you run the C++ opencv functions from a standard c++ project? If so, the problem is just about your project configuration.

Resources