I hava built vtk6.3 with qt5.5 on ubuntu 64bit,and I open an example with qtcreator.Build it,then link error occur:
Generic Warning: In /VTK/Rendering/Core/vtkRenderWindow.cxx, line 40
Error: no override found for 'vtkRenderWindow'.
The line 40 with doc:
//Use the vtkAbstractObjectFactoryNewMacro to allow the object factory overrides.
vtkAbstractObjectFactoryNewMacro(vtkRenderWindow)
I google for this problem,almost all explanation is about this link,it seems I must add this macro in my cpp file to enable the factory methord:
include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingWindow)
But I got another error:
error: undefined reference to `vtkRenderingWindow_AutoInit_Construct()'
error: undefined reference to `vtkRenderingWindow_AutoInit_Destruct()'
I can't find any built library define these symbols,google it and I got almost nothing.I am new to vtk,can anyone give some help?
Use VTK_MODULE_INIT(vtkRenderingOpenGL) instead of VTK_MODULE_INIT(vtkRenderingWindow). It works for me.
this is an old thread, but just in case...
If you are not using cmake with your VTK project you may run into the link "error: undefined reference to".
How can you find out the right library out of the (v6.1: 377) vtk libraries available, when the documentation gives no hint?
Solution: in headers there usually is an EXPORT macro like this:
class VTKCOMMONDATAMODEL_EXPORT vtkCellArray
this gives a hint for the library: in this case libvtkCommonDataModel
In regardto the problem with
undefined reference to `vtkRenderingOpenGL2_AutoInit_Construct()'
I had used the macro
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
Solution: on my system there is only a libvtkRenderingOpenGL. So change the VTK_MODULE_INIT line and add linker option -lvtkRenderingOpenGL to the command.
Related
I'm trying to integrate ffmpeg library to an android ndk project. I followed this documentation. When i try to call a method from avcodec library like as av_malloc, there is no problem. But when i try to call av_rdft_init or av_rdft_calc methods, ndk gives errors like as;
error: undefined reference to 'av_rdft_init(int, RDFTransformType)'
error: undefined reference to 'av_rdft_calc(RDFTContext*)'
I can see those methods in header file and also see in libavcodec.so file's symbol table but could not build with ndk.
Any ideas to fix this problem?
Thanks in advance.
Problem fixed by adding LOCAL_ALLOW_UNDEFINED_SYMBOLS := true to android makefile
I'm trying to use SDL 2.0 in Qt Creator 3.1, using the Qt Build Suite (QBS) in Windows 7.
I've put the links in my .qbs to locate the SDL folders and I think everything works ok, because in my main.cpp it's recognizing the SDL functions, trying to autocomplete them.
The problem is, whenever I try to compile, I get the 'undefined reference to WinMain#16'
I'm using MinGW and set in the Compiler preferences the linker flags to: -lmingw32 -lSDL2main -lSDL2 -mwindows
The output is:
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main.o): In function `main':
e:\p\giaw\src\pkg\mingwrt-4.0.3-1-mingw32-src\bld/../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/main.c:91: undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
And my .qbs is:
import qbs 1.0
CppApplication {
name: "testeSDL2"
cpp.includePaths: [".",
"C:/SDL2-2.0.3/i686-w64-mingw32/include"]
cpp.libraryPaths: [
"C:/SDL2-2.0.3/i686-w64-mingw32/lib"]
cpp.dynamicLibraries: "SDL2"
files: [
"main.cpp"
]
qbsSearchPaths: "C:/CppLibs/"
}
I've been searching a lot and only find answers for common Qt projects using the .pro but not the .qbs... And there's a section in the SDL site that says it's a linker problem, but I set them in the preferences window, my guess is that I also need to set them somehow in the .qbs file, but I don't have a clue on how to do so. Can anyone help?
As I recall, SDL defines a macro main that expands to some SDL-specific function name.
Find that macro definition and you also find the macro symbol you need to disable that thing.
Oh well maybe this should have been a comment not an answer, but when/if you find that (sorry I don't have time to check those sources) then you can mark this as “the solution”, he he. :-)
Addendum: since the OP kindly posted the SDL code, I've looked at it and found this comment:
“If you provide your own WinMain(), you may define SDL_MAIN_HANDLED”
… before including the SDL headers.
Then the macro called main is not defined.
I just downloaded http://dev.mysql.com/downloads/mirror.php?id=414392 and set include/bin/lib folders to my compiler(tdm-gcc 4.8.1) in dev c++.
I can use functions from mysql.h (#include )
But i cant compile program.
bcoz:
undefined reference to `mysql_init'
undefined reference to `mysql_select_db'
what i have to do?
You've got the '-L' arguments including the lib directories, but you don't appear to have a '-l' argument linking the actual library. I think what you want to add is '-lmysqlclient' or something similar. Please see the following page for more information:
http://dev.mysql.com/doc/refman/5.0/en/c-api-building-clients.html
My project has a function that clears the terminal, which is implemented using the curses library. Compiling with the -lcurses flag works fine, but compiling without yeilds
/tmp/cc3T2MVI.o: In function `ClearScreen()':
clear_term.cpp:(.text+0xb): undefined reference to `cur_term'
clear_term.cpp:(.text+0x26): undefined reference to `setupterm'
clear_term.cpp:(.text+0x37): undefined reference to `tigetstr'
clear_term.cpp:(.text+0x3f): undefined reference to `putp'
collect2: ld returned 1 exit status
This is obviously expected because it cant find the library, but because this functionality is supplemental it would be preferable to define ClearScreen() as an empty function than to have compilation fail. I know that I put the function definition in a #ifdef block but I don't know any flags defined by curses.
Is it possible to catch these errors and instead define ClearScreen() as an empty function?
You can define a macro in the Makefile:
use_curses=1
FLAGS+=-DUSING_MAKEFILE
ifeq ($(use_curses),0)
FLAGS+=-DNO_NCURSES
else
LIBS+=-lcurses
endif
And in the code:
#ifndef USING_MAKEFILE
# error "Please use provided Makefile to compile!"
#endif
#ifdef NO_CURSES
void ClearScreen() { }
#endif
Actually, that is a linker error. And no, it can't really be caught at compile time. But one possibility would be to load the shared object dynamically in ClearScreen. If it failed to load the library, then it could just return. Doing the check at run time may be preferable to build time checks if you are not guaranteed to be building the binary on the target system on which it will ultimately be running.
You really need this library.
Maybe it will help you: http://linux.die.net/man/3/tigetstr
What you are trying to do (configuring the project with respect to dependencies) — is the classical task of build systems.
For example, with CMake, you'll have FindCurses module, which defines CURSES_FOUND preprocessor variable (if it founds the library).
With GNU Autotools you'll have similar macro, consult the relevant documentation.
If you're using your own build system — then you have to manually code the handling of relevant flags in configuration time.
Your build script should detect whether a suitable version of curses is present on the build machine. You can generate such script with GNU Autotools for example (the result iwould be a familiar configure script. You can also write a simple custom script insh/bash.
The problem you haven't considered is that your code probably #include's ncurses.h, which won't ever work without the library being installed where the compiler can find it.
i was doing an opengl program and it so happens i had to use some functions in the math3d.h header and i copied it to the local directory and included
inlcude "math3d.h"
but i get an error
transform.cpp:(.text+0x3da): undefined reference to `m3dRotationMatrix44(float*, float, float, float, float)'
collect2: ld returned 1 exit status
where m3dRotationMatrix44 is a function in math3d
usually i used for glut the switch -lglut
SO for this what am i to do?
Thanks i advance
How did you install Math3D?
If you want to do all locally you will also need to copy the library file to your local directory and add it to your link command, ie -lmath3d if the file name is libmath3d.a
If you mean math3d from the OpenGL Super Bible you can try to add the math3d.cpp to your project/makefile
http://andrewtolbert.com/svn/personal/OpenGLSuperBible/shared/math3d.cpp
When gcc says "undefined reference" it means that you missed one or more libraries to link against. You need to find out what package math3d.h came from and link against the library inside that package.