Building a class inherit from QWidget but with _ZTVXYYY undefined - gcc

I am building the analogClock (class AnalogClock : public QWidget) example application under qtbase/example/widgets, but with following undefined symbol: _ZTV11AnalogClock...
And I objdump -t analogClock.exe to try find who reference this symbol, but nothing found...
MORE INFO:
As long as the class inherit from QWidget, and construct a object, then there will be a undefined symbol _ZTVXYYY, where X is the length of the class name, YYY is the class name.
so could you someone help point out what's this _ZTVXYYY symbol ?
And how to avoid this situation ?

It's caused by the Makefile is not generated by the correct qmake tool.

Just as #thincal said, if Qt project is not properly configured, qmake will generate incorrect Makefile.
For example, if I'm writing a PLUGIN which inherits from QWidget, I have to:
Add Q_OBJECT macro in the top of class definition;
Add CONFIG += plugin in the project config file (with .pro suffix).

Related

java.exe exited with code 1

I'm using vs 2017 and xamarin.forms.
I'm getting the error "java.exe exited with 1" in the release mode with ProGuard turned on. (in the debug & without proguard its doing fine) It's a common question, i know , but i've tried all the variants and it still doesnt work.
1.tried to update proguard to 5.3 version manualy
2.to update jdk 8, to install either x64 or x86 or both
3.to change the java memory to 1g , 4g, 500 m
4.to turn on multi-desk
to edit the proguard-android.txt by adding
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
(These just ignore proguard, google play doesnt accept it.)
ANY OTHER VARIANTS HERE?
com.google.android.gms.gcm.GcmNetworkManager: can't find referenced method 'java.lang.Object zzb(java.lang.Object,java.lang.Object)' in program class com.google.android.gms.common.internal.zzu
there were 3 unresolved references to program class members.
com.google.android.gms.gcm.GcmNetworkManager: can't find referenced method 'void zzb(boolean,java.lang.Object)' in program class com.google.android.gms.common.internal.zzu
there were 1 unresolved references to library class members.
com.google.android.gms.gcm.Task$Builder: can't find referenced method 'void zzb(boolean,java.lang.Object)' in program class com.google.android.gms.common.internal.zzu
com.google.android.gms.gcm.zza: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification

Why am I getting duplicate symbol linker errors when building in CMake on Windows?

I have a CMake setup to link together 4 static libraries and 1 shared one into a top level shared library (Let's call it Top.dll). This will work fine except for one thing. I have a module definition file that expresses which symbols should be public. Top.dll builds and so far so good.
Now when I try to link an executable with Top.dll via CMake I get linker errors for every public symbol claiming it is defined in two places (Top.dll and the static library in which it was actually defined) even though Top.dll contains no original definitions of its own. If I remove the static library then as expected I get unresolved symbol errors. If I remove the module definition file, I get the same. It seems like it is either there zero times or twice. Is there some setting I am missing here? I don't think I'm using CMake in a non-basic way...
UPDATE An explanation via CMake
# setup the lib
add_subdirectory(vendor/A) #shared library
add_subdirectory(vendor/B) #static library
add_subdirectory(vendor/C) #static library
add_library(Top SHARED ${ALL_SRC_FILES})
target_link_libraries(Top A B C)
set_target_properties(Top PROPERTIES LINK_FLAGS
"/def:${PROJECT_SOURCE_DIR}/definitions.def") #contains symbols from B
add_subdirectory(C/Tests)
# CMakeLists.txt from C/Tests
add_executable(Tests ${SRC_FILES})
target_link_libraries(Tests Top)
The above is simplified, but I will get errors like the following at the point that the C/tests project is compiled:
B.lib(xxx.obj) : error LNK2005: _ABC already defined in Top.lib(Top.dll)
If I remove B.lib from the target_link_libraries call, then as expected I get unresolved symbols. If I remove the /def line, same result.
I've been able to get around this by setting the target_link_libraries of B and C to private. This may or may not be the correct solution and I will wait for other answers. If I don't do this it appears that the dependency is carried up to the final executable (So it links to both Top.dll and B.lib, etc).

Does proguard support GCM?

I receive this error when I try to rebuild app with proguard: (I tried all the solutions suggested for the error MSB6006: "java.exe" exited with code 1, but in my case, it seems have some conflicts with GCM )
19>PROGUARD : warning :
com.google.android.gms.common.GooglePlayServicesUtil: can't find
referenced method 'void
setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)'
in class android.app.Notification 19>PROGUARD : warning :
com.google.android.gms.gcm.zza: can't find referenced method 'void
setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)'
in class android.app.Notification 19> You should check if you
need to specify additional program jars. 19>PROGUARD : warning : there
were 2 unresolved references to program class members. 19>
Your input classes appear to be inconsistent. 19> You may
need to recompile them and try again. 19> Alternatively, you
may have to specify the option 19>
'-dontskipnonpubliclibraryclassmembers'. 19> java.io.IOException:
Please correct the above warnings first. 19> at
proguard.Initializer.execute(Initializer.java:321) 19> at
proguard.ProGuard.initialize(ProGuard.java:211) 19> at
proguard.ProGuard.execute(ProGuard.java:86) 19> at
proguard.ProGuard.main(ProGuard.java:492) 19> Picked up
JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 19>C:\Program Files
(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2118,3):
error MSB6006: "java.exe" exited with code 1.
The Google GMS libraries sometimes try to access library methods that are not available for a given target SDK version and gracefully handle errors at runtime. So it is usually required and safe to add something like this to ignore such warnings:
-dontwarn com.google.android.gms.**
-dontnote com.google.android.gms.**
These rules will ignore all warnings and notes from the gms libraries.
I solved it with this solution from Xamarin forum:
Create file named proguard.cfg inside Android project in the solution. Right click and set Build Action to ProguardConfig.
Add the following lines:
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
Amend the above according to type of errors you're getting
Make sure you save file as UTF-8 and NOT UTF-8 BOM
Compile version: 6.0
Min target: 5.1
Target version: 6.0

Compiling Bzip2 with C++11

I'm trying to compile the MultiBoost Library with C++11 but I can't make it work. The problem seems to be with the BZip2 Library that is used internally. More specificly there is a wrapper called Bzip2Wrapper to provide a c++ interface to the C library. All the files of the C library are included in the same folder. When using the default make file everything works but when I change
project(multiboost)
to
project(multiboost CXX)
I get the following errors:
libMultiBoostLib.a(Serialization.cpp.o): In function `Bzip2WrapperReader::open(char const*)':
Serialization.cpp:(.text._ZN18Bzip2WrapperReader4openEPKc[_ZN18Bzip2WrapperReader4openEPKc]+0x97): undefined reference to `BZ2_bzReadOpen'
Serialization.cpp:(.text._ZN18Bzip2WrapperReader4openEPKc[_ZN18Bzip2WrapperReader4openEPKc]+0xc5): undefined reference to `BZ2_bzReadClose'
libMultiBoostLib.a(Serialization.cpp.o): In function `Bzip2WrapperReader::close()': ...
The CMakeList file looks like this
# Bzip2
file(GLOB bzip2_SRCS "${BASEPATH}/Bzip2/*.cpp" "${BASEPATH}/Bzip2/*.c" "${BASEPATH}/Bzip2/*.h")
add_library(Bzip2Lib STATIC ${bzip2_SRCS})
#add_library(bzip2 SHARED ${bzip2_lib_SRCS})
...
# adding library to the exec
target_link_libraries(multiboost MultiBoostLib Bzip2Lib)
Any ideas what could go wrong? I don't even know what the problem is.
Thanks!
This does not look like a C++11 error but an error in the Build system.
I have not looked at the Code, but from the output you added something like this
target_link_libraries(MultiBoostLib PUBLIC Bzip2Lib)
should add the missing dependency from libMultiBoostLib on libBzip2Lib.
I found the problem. I was adding "CXX" to my project description which disabled the use of C. Therefore the libraries (in C) could not be compiled. Changing it to "project(name C CXX)" solved this issue. I then also needed to include the line "set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")" to enable C++11 support. Now everything is working.
Thanks a lot!

Problem in adding static library in cocoa application

I am having liavcodec.a static library and header files of this library.
libavcodec.a
I added this library and their header files into my project and there is no error. I can see this library added in Target->Info->General and i have edited the Header Search Path also.
I can add header file #import “avcodec.h” into xcode project also. I can use all the variables which have been declared in structure of that file. But i am trying to use any function from that class, i am getting some errors like,
Test.m
—-
“-avcodec_register_all”, referenced from:
-[Test initialize] in Test.o
Symbol(s) not found
collect2: id returned 1 exit status
—-
Do you what is the problem?
Many thanks.
Provide implementation of your [test initialize] method. Also provide the configuration command which you used to build the static library.
Try rebuilding the library, the method avcodec_register_all should be directly accessible through allcodecs.c file if the library is included in target and header search path is properly configured. Probably the library is corrupt, just as tedge says.
Just as a sanity check, verify that your library file contains the expected symbols; Type this in a terminal window (replacing path/to with the correct path):
nm -g /path/to/libavcodec.a | grep avcodec_register_all
(If the command's output is just a blank line, then the library file is probably corrupt).

Resources