(LINUX)Porting from Qt4 to QT5 undefined symbol : _Zn9Qwidget11stylechangeER6QStyle - c++

I ported my application from qt 4.8.0 to qt 5.5.1
It compiled without any error but at run time the application crashes and get the message undefined symbol : _Zn9Qwidget11stylechangeER6QStyle in one of my .so file linked dynamically.
When searched couldn't find any function styleChange() in whole project source code.
Cleaned project, deleted all intermediate files, all object files, .so file but same result.
It seemed it is a qt4.8.0 function but could'nt find and hence not able to debug.
Any help would be appreciated.

When searched couldn't find any function styleChange() in whole project source code.
Note that in the mangled name 'c' is in lowercase: stylechange. Have you tried to search for this method?

Related

Receiving the error "undefined symbol" when loading C++ dynamic library from C executable

I am trying to write a plugin for a popular program whose code and compilation process I do not have control over. The program is written in C. However, I have written parts of my plugin in C++, since I use the QT5 library for graphics capabilities. The functions that the C program calls are written in C.
When the C program tries to load the plugin (shared library), it produces this error:
dlopen('build/libfoo.so') failed: build/libfoo.so: undefined symbol: _ZTV13JoystickPanel
JoystickPanel is a class in the C++ part of the program.
I've tried rewriting parts of the program in C, but the error was unaffected. I know that I could rewrite the entire program in C, but I'd rather not have to switch to another, more C-friendly GUI framework. I've also opened up libfoo.so in a text editor and search for JoystickPanel, but it appears to be mangled as _ZN13JoystickPanel.
Are there any compiler options or solutions that I'm missing?
I have no idea what _ZN13JoystickPanel means, since it's not apparently a valid mangled C++ name. It should perhaps be _ZN13JoystickPanelE, which would translate to JoystickPanel. That'd be symbol name for sure, but without much meaning anyway. You must have truncated something: I tried quite a bit and just can't generate an object file that would include _ZN13JoystickPanel as the complete symbol. It's just a prefix, there should be a "second half" attached to it - was there?
But _ZTV13JoystickPanel is the vtable for the JoystickPanel class. It's missing because you didn't provide implementations for all the virtual methods of the JoystickPanel class. Most likely, you didn't invoke moc properly, or forgot to compile and link its output.
You need to show a complete build script for your plugin at the very least (the .pro file, or CMakeLists.txt). You'll also need to provide a github link to your project (I presume it's open source).
The symbols you want to find in the compiled output are at least _ZTV13JoystickPanelD#Ev - virtual destructors, where # is a digit, _ZTV13JoystickPanel - the virtual method table,
Those symbols may be absent when compiled with optimization and/or LTCG, but also absent will be references to them.
You may wish to delete the build folder and rebuild your project, just to be sure. qmake is bad at dependency generation for the makefiles it produces, so if you use it, I suggest switching to cmake + ninja.
Apparently, I'd forgetten to put the #include "moc_controller.cpp" line at the bottom of a file that needed it.
For anyone else chasing this issue while using Qt on CMake, consider making sure that the proper lines are added.

How to build the Poco C++ libraries

I'm trying to build the Poco C++ libraries manually on Android, iOS, and windows. After much effort I got them to build on Android, but I'm struggling a bit on Windows.
I've had to manually edit several files already to resolve undefined symbols -- specifically File & Path weren't #included properly by *_WIN32U.cpp versions.
I'm down to what APPEARS to be my last compiler issue for "Foundation". It's this line in Process_WIN32U.cpp:
envChars = getEnvironmentVariablesBuffer(env);
The compiler error generated is:
"getEnvironmentVariablesBuffer identifier not found"
The declaration of "getEnvironmentVariablesBuffer" is in Process.cpp but it's not a member of the root class, there are no EXTERN references anywhere, and no header file contains the function declaration.
So how the heck is "Process_WIN32U.cpp" supposed to be able to see that function?
Thanks!
So how the heck is "Process_WIN32U.cpp" supposed to be able to see that function?
ProcessWIN32U.cpp (i.e. ProcessImpl class) is able to see that function because ProcessWIN32U.cpp is included from Process.cpp and it was not designed or meant to be used standalone - it is excluded from build in POCO Visual Studio solutions.
In order to get ProcessWIN32U.cpp to be included by Process.cpp, one must manually /D_WIN32 which is not defined by Visual Studio (it defines WIN32).

c++ boost library Entry point could not be located

I have a c++ Lib project StoreLib, and I have UnitTest Project where I wrote a unit test to test a functionality of class in StoreLib. StoreLibuses bunch of external dlls
My boostTest project compiles and when I run the exe, it complained about missing bunch of dlls, I pasted all of them in my bin folder. Then get this weird error
Store.UnitTests.exe - Entry Point Not Found.
The procedure entry point could not be located in the dynamic link library C:\UnitTest\UnitTests.exe.
First I am unable to understand why is it treating an exe file (UnitTest.exe) as a dynamic link library ? if I write a simple test i.e. Boost_Check(6==6) with out referring to any header file in my StoreLib it works just fine, though moment I refer to any header file from StoreLib it gives above mentioned error.
Any clue what I am doing wrong ? any help would be appreciated
it turned out that the one the external dll included was old, perhaps it was not finding proer entry point

link static library in c++ visual studio

can someone please help me to understand the process.
in c++ visual studio 2010
i have a visual studio solution (lets call it mysol)
i have a project built as a static library (let's call it staticprj)
staticprj needs to use a library from outside (lets call it ext.lib)
in the body of the source code of staticprj i include outside library header file with
# include extlib.h and make calls to some of its functions (let call them extfunctions())
i also include the the path to the header files location of the ext.lib.
the staticprj compiles okay without errors
the mysol also has another project which is a dynamic library (dynprj) and which depends on the staticprj.
also in the source files of the dynprj uses functions from outside library.
i have included #include extlib.h in the source code of dynprj.
i have included the path of the header files
i have attached extlib.h directly to the dynprj
i have also added ext.lib to the linker input (along with the path where the ext.lib resides).
i still get a lnk2001 error stating that extfunctions() where not found.
the whole structure (the mysol solution) compiles okay if i do not use ext.lib at all.
my question is how does the linking process works and what can i do to correct this linking error.
(note that without the presence of ext.lib my linking of the staticprj and dynprj is fine. my compilation works okay and my code works. i only get the linking error when i try to link another ext.lib to staticprj and dynprj and use functions from ext.lib)
thanks in advance.
I'm not quite sure it will work, but try putting the .dll inside your "mysol" debug folder. I had a similar problem couple of weeks ago when I had library compiled as .dll. I just placed that .dll within my debug folder and worked lovely.

Xcode beginner needs help starting debugging

I'm a novice C++ programmer and I only know how to program in visual studio, but my PC crashed and I only have mac Xcode available.
I wrote a .cpp like in visual studio, but when I had it build, it gave me this error..
ld: duplicate symbol _main in /Users/karen/Desktop/BD/build/BD.build/Debug/BD.build/Objects-normal/x86_64/bd1.o and /Users/karen/Desktop/BD/build/BD.build/Debug/BD.build/Objects-normal/x86_64/main.o
Anyone know what to do?
This error is telling you that you have defined "main" in two separate files: (probably "bd1.cpp" and "main.cpp"). If you didn't create the file "main.cpp" (or "main.cc"); it's possible that XCode created a sample "main" for you when you set up the project.
A program can have only one function named "main", so you need to get rid of one of them...
Its a linker error, so you can't really "debug" this.
Can we see some code? bd1 and main have a duplicate symbol - so u use maybe same variable/function names without namespaces? Its also possible, that you need to "cleanup" before you try to build (old symbols in object files) - but its like guessing without seeing your code...
Either bd1.cpp or main.cpp should go, as they both have a main function. There can only be one main function in a C/C++ program. Most likely main.cpp was automatically created for you when you created a new Xcode project for existing codebase. So search for main.cpp/main.c in your project and remove it.