I'm beginning my OpenGl course and I'm using the book by Edward Angel, Interactive Computer Graphics. In the first example in the book he uses glsl shaders. I have successfully linked all compiler libraries to correct compiler flags etc.
Im stuck with error message undefined reference to 'Angel :: InitShader(char const*, char const*)' Im using code::blocks as IDE on Linux Fedora 20.
If I trace the error then it's refering to GLuint program = InitShader( "vshader21.glsl", "fshader21.glsl" );
the files vshader21.glsl and the other file are in my source folder so it defenitely knows about is.
In the header file angel.h the shader files are initialized under the namespace Angel.
GLuint InitShader( const char* vertexShaderFile,
const char* fragmentShaderFile );
If someone is interested to see the cpp, glsl and h files. They are all here http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/CODE/CHAPTER02/MAC_VERSIONS/
You need to add InitShader.cpp (where the function InitShader is defined) to your project as well as the header file.
Related
I'm creating an C++ static library with code::blocks that call functions of the SDL library. The library compiles OK. I created annother project that will use the library I've created, all the build options are OK, I set the linker to work with the SDL and everything else, but, when I try to compile the project, I got Undefined Reference in the SDL functions. I solve this trouble by putting an call to SDL_Delay(1) function in the end of the main function.
It seems that the linker only found the SDL functions when I call at least one of them in the project that I'm compiling. Exist an more correct way to solve this?
example:
#include "HW_Engine" // My static link library
void main(int argc, char *argv[]){
HWE_Core *Engine_Core = new HWE_Core(); // this constructor calls some SDL functions
...
SDL_Delay(1); // If I omit this, I have an Undefined reference for all the
// SDL functions called in the HW_Engine library
}
thanks for the help!
I am trying to compile a program with Netbeans (g++) that inlcudes Aquila, an open source libary. I followed the installation instructions.
But when trying to compile a small test program, I get this error
In function `Aquila::OouraFft::fft(double const*)':OouraFft.cpp:(.text+0x24f):
undefined reference to `cdft'
OouraFft.h:
#include "Fft.h"
extern "C" {
void cdft(int, int, double *, int *, double *); //prototypes of offending function
void rdft(int, int, double *, int *, double *); //second one.
}
The C file in the libs folder contains the definition of the functions.
The line that cause the actual error in
OouraFft.cpp:
// let's call the C function from Ooura's package
cdft(2*N, -1, a, ip, w);
So I am thinking the external C file is not being linked with the project but included all the directories in the project directory.
I have been googling for hours and can't figure it out.
Up to git version 6f5d6b, Aquila's CMake config will generate static library by default. You should copy /path-to-your-build-tree/lib/libOoura_fft.a to /path-to-your-install-dir/lib/, and link it to your test program.
As Answeror said you need to put libOoura_fft.a in the right place (/usr/local/lib is the default for libAquila.a).
You also need to link to it as Chris Vandevelde said, but you should link to -lOoura_fft (first "O" capital). You should be linking with -lAquila as well
Just wanted to clarify.
I started the tutorial for opencv 2.4.7 on Win8, latest MinGW, and Eclipse Kepler R1, CDT. C++ Compiler includes are referencing to [path-to-opencv]\open247\build\include.
in the MinGW C++ Linker I add the library path [path-to-opencv]\open247\build\x64\vc11\lib. The vc11 directory contains libraries for VisualStudio from what I've read. Is that still okay to compile them with MinGW?
I added the core and highgui library for this sample (I don't think we need more than those).
However, for this simple idle code below, I provoke the following compilation error.
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(){
Mat image;
}
The error on compilation is:
Description Resource Path Location Type
undefined reference to `cv::fastFree(void*)' FirstOpenCV line 278, external location: C:\Users\John\Documents\Software\opencv247\build\include\opencv2\core\mat.hpp C/C++ Problem
What's the reason for this?
If I add
namedWindow("testWindow", 1);
I even get this error
Description Resource Path Location Type
undefined reference to `cv::namedWindow(std::string const&, int)' main.cpp /FirstOpenCV/src line 23 C/C++ Problem
Have you link correctly your library?
-lopencv_core
-lopencv_highgui
-L<opencv_library_path>
The libraries have to be specified after the source file on the compiler/linker command line. (The linker keeps track of unresolved symbols, and resolves them via later command-line arguments.)
I'm trying to compile the SDL libraries with Visual C++ (2010), and with Visual Leak Detector as to find a memory leak in another program that calls SDL.
The problem is that vld.h is a C++ library, and SDL.c is a C program. Accordingly, when I #include , the source doesn't compile as VLD seems to use a C++ specific constructs:
typedef int (__cdecl * VLD_REPORT_HOOK)(int reportType, wchar_t *message, int *returnValue);
__declspec(dllimport) int VLDSetReportHook(int mode, VLD_REPORT_HOOK pfnNewHook);
I've attempted compiling SDL.c as a C++ program, but I get a plethora of errors.
Is there any way I can include VLD in SDL?
(with thanks to #Matias Valdenegro)
The problem was the wchar_t. To be able to recompile SDL (and I assume other C source files) to include VLD, add
#include <wchar.h>
to both vld.h and vld_def.h. SDL will then happily compile, and can be used with an SDL program to detect memory leaks stemming from Surfaces and the like.
After looking around for various sound API libraries, I have decided to use FMOD for the time being.
Problem is that whenever I try to compile one of the code examples, I get the following errors:
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::getVersion(unsigned int*)#8'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::init(int, unsigned int, void*)#16'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::System::createSound(char const*, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::Sound**)#20'|
obj\Release\main.o:main.cpp|| undefined reference to `FMOD::Sound::setMode(unsigned int)#8'|
The code example that I am using being this:
#include <D:\Games\FMOD Programmers API Win32\api\inc\fmod.hpp>
#include <D:\Games\FMOD Programmers API Win32\api\inc\fmod_errors.h>
#include <sstream>
#include <windows.h> // for PlaySound()
#include <time.h>
#include <mmsystem.h>
using namespace std;
int main(int argc, char* argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2, *sound3;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
result = system->getVersion(&version);
result = system->init(32, FMOD_INIT_NORMAL, 0);
result = system->createSound("../media/drumloop.wav", FMOD_HARDWARE, 0, &sound1);
result = sound1->setMode(FMOD_LOOP_OFF); /* drumloop.wav has embedded loop points which automatically makes looping turn on, */
/* so turn it off here. We could have also just put FMOD_LOOP_OFF in the above CreateSound call. */
// Code continues into other bits that work...
I am using the latest version of FMOD and am using the Code::Blocks IDE (ver 10.05), with the GNU GCC compiler. The project is of type "Console application". The fmodex.dll file is in the folder of my project. I am using windows XP 32 bit SP3.
I have linked to the libfmodex.a library and have tried linking to the other libraries it has there as well, but this does not solve the problem.
My question is, therefore, what do I need to do to stop these errors occurring? As when I encountered similar "Undefined reference to x" errors before using other libraries. I had just forgotten to link to them in Code::Blocks and as soon as I did, they would work.
Do say if you need more information regarding the code etc.
When using FMOD with Code::Blocks you need to use the C API, not the C++ API. FMOD is built with Visual Studio, therefore the C++ symbols use the VC mangling scheme. There is a note in the "Getting Started with FMOD for Windows" document that mentions this.
http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions
I do not have a Windows box ready to verify this on, but try replacing those backslashes with forward slashes in the include paths, or escape the backslashes.
#include <D:/Games/FMOD Programmers API Win32/api/inc/fmod.hpp>
#include <D:/Games/FMOD Programmers API Win32/api/inc/fmod_errors.h>
or
#include <D:\\Games\\FMOD Programmers API Win32\\api\\inc\\fmod.hpp>
#include <D:\\Games\\FMOD Programmers API Win32\\api\\inc\\fmod_errors.h>
(Or, better, just add D:\Games\FMOD Programmers API Win32\api\inc\ to your list of include paths, and include the files by filename instead of full path; then your code might actually compile somewhere other than your specific computer!)
Those undefined reference errors mean that the compiler, or rather the linker part of the compiler, cannot find the library.
I don't use Code::Blocks so I don't know where the setting is, but you need to tell your project to use the library and where to find it.
Just putting the DLL in the directory is enough for running the program, but for linking it you need a .lib file.