cannot link with glew32 for "glewInit()" - linker

#include <gl/glew.h>
int main()
{
glewInit();
glActiveTexture(GL_TEXTURE0);
return true;
}
I've already set up header search path, library search path, glew32.lib & opengl32.lib. However Visual Studio 2012 cannot link with
error LNK2019: _imp_glewInit
The strangest thing is that I can link glActiveTexturet ( or *__glewActiveTexture* ), but I cannot link glewInit

OK finally I got it...I use glew from cuda, which absolutely has some problems... I overwrite glew.h & glew32.lib from sourceforge, which works now...

Related

Undefined reference to (Quickmail)

I am looking for how to install quickmail.
I put quickmail.h here: C:\Program Files\CodeBlocks\MinGW\include, the .a and .la here: C:\Program Files\CodeBlocks\MinGW\lib.
I linked these .a files by adding them in the linker settings. I also did include the library like this: #include <quickmail.h>, but the functions are not recognized.
What should I do ?
The 4 files in the bin folder are in the project folder and I downloaded files from here : quickmail - Sourceforge.
EDIT : I get \main.c|9|undefined reference to '__imp_quickmail_initialize'| \main.c|10|undefined reference to '__imp_quickmail_create'| \main.c|11|undefined reference to '__imp_quickmail_set_body' and I put C:\Program Files\CodeBlocks\MinGW\include in search directories.
This is the code :
#include <stdio.h>
#include <stdlib.h>
#include <quickmail.h>
int main()
{
const char* error;
quickmail_initialize();
quickmail mailobj = quickmail_create("aaa#gmail.com", "libquickmail test e-mail");
quickmail_set_body(mailobj, "This is a test e-mail.\nThis mail was sent using libquickmail.");
quickmail_add_attachment_file(mailobj, "words.txt", NULL);
if ((error = quickmail_send(mailobj, "smtp.gmail.com", 587, "aaa#gmail.com", "MAGA2020")) != NULL)
fprintf(stderr, "Error sending e-mail: %s\n", error);
quickmail_destroy(mailobj);
return 0;
}
Sorry, the site gave me the wrong version.
To use a library you need to include the header in the code (in this case #include <quickmail.h>) and if needed tell the compiler where to find this file (the full path to the lib folder) with the -I compiler flag.
Next you need to tell the linker to link with the library (in this case -lquickmail or -lquickmaillight) and if needed where to find this file (the full path to the lib folder) with the -L linker flag.
Your errors are linker errors, so it seems the second step wasn't properly done.
In Code::Blocks it looks like this (though unlike the screenshots you should set it at the top-level instead of just for Debug builds):

Correct command line parameters for gcc compilation of SDL

I recently started SDL2.0 programming.
I did a lot of researches and i tried all but i still get those "undefined reference" errors for all the SDL functions:
undefined reference to `SDL_Init'|
undefined reference to `SDL_GetError'|
undefined reference to `SDL_Quit'|
||=== Build finished: 3 errors, 0 warnings ===|
on that simple test program:
#include <stdlib.h>
#include <stdio.h>
#include "SDL.h"
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) {
fprintf(stderr, "\nUnable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
return 0;
}
If i have to guess the problem occurs due to the wrong command line syntax.
In this case what should be the correct one?
You aren't linking to the SDL libraries correctly.
Add the following lines int Other Linker Option
-lSDL -lSDLmain
mingw32
SDLmain
SDL
Also You need to check setup for how to compile SDL in codeblock
http://wiki.codeblocks.org/index.php?title=Using_SDL_with_Code::Blocks
http://lazyfoo.net/SDL_tutorials/lesson01/windows/codeblocks/
If it's not too late then try from the beginging to how to set up SDL in codeblock and successfully run it? Below link provide you exact steps for it.
http://www.dreamincode.net/forums/topic/57275-setting-up-codeblocks-to-work-with-sdl/
You might have not linked SDL2 correctly to your CodeBlocks project and not referred to SDL2 correctly in your code.
1:
Go to "Linker options" in "Build Options" menu and make sure you have added these library's to your project like this:
Library's to include in linker options
Importent!: save project before running it after adding/changeing library's.
2:
Change:
#include "SDL.h"
to this:
#include <SDL2/SDL.h>
if you still encounter problems compiling and running it, it's most likely either, your SDL2 files not placed correctly in the compiler's folders, or your using an version of gcc with some missing tools.
These Youtube video's explain everything in great detail:
1: https://www.youtube.com/watch?v=x0LUf7Ibpi0
2: https://www.youtube.com/watch?v=EtUw_7CvRRo

Problems with GLEW using MinGW: Undefined reference to '_imp__glewExperimental.'

I'm using GLEW version 1.10.0 with MinGW (Through the CodeBlocks IDE), running on Windows 8. I downloaded the Windows binaries from the GLEW website, and have been linking to the libraries included with that build.
I have a linking problem that I just can't seem to find an answer to. I have followed the installation on the GLEW home page. I have referenced the linker to the glew32.lib, as well as the other required libs such as opengl32 and glu32.
Unfortunately, compiling this code (I'm also using GLFW for context/window management):
#include <stdio.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#define TRUE 1
#define FALSE 0
int main()
{
GLFWwindow *window;
if (!glfwInit())
return -1;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3.0);
window = glfwCreateWindow(640, 480, "Hello World!", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
glewExperimental=TRUE;
GLenum err = glewInit();
if (err!=GLEW_OK)
fprintf(stderr, "Could not initialize GLEW!");
printf("%s\n", glGetString(GL_VERSION));
while (!glfwWindowShouldClose(window))
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I get the error:
*undefined reference to imp_glewExperimental*
Even though I'm new to C, as far as I understand, this means that I'm referring to something which has no definition, which generally means the library is missing. In this case though, I have included the library, and I got no errors whatsoever about the other GLEW references I make, such as glewInit, which I feel it should also complain about should it be a problem of missing libraries.
I've tried to search the web but I simply haven't found anything on this problem.
Anyone got any ideas? :)
Thank you all very much for your time. It is much appriciated.
It seems I have solved the problem. For anyone who'd like to know, it appears the problem was the pre-build Windows binaries from the GLEW website, because they originate from Visual Studio (they are .lib files). I was using MinGW to do compilation. As soon as I tried to compile GLEW myself using MinGW to create a .a archive, it worked.
There's already a great answer here on stackoverflow on how to compile GLEW for MinGW, and can be found right here.
try to put #define GLEW_STATIC on the first line:
#define GLEW_STATIC
#include <stdio.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
and put -lglew32s first in the link libraries table.
codeblocks:
project > build options... > linker settings > add glew32s
then click the up arrow until it get first

Hello World (C and C++) for WinCE application - Visual Studio 2008

I'm a beginner for Visual Studio 2008 (32-bit). The WinCE version I'm using is 7.0 Evaluation. I created a new project as,
New Project -> Platform Builder-> OS Design
Selected the BSP as,
BSP: Generic CEPC:x86
When the design template highlighted Consumer Media Device, I just clicked Finish.
The above selections are a must for me. Besides these, I created a subproject as a simple hello world application and added a line cout<<"Hello World"; (as they are by default cpp files). I also included iostream.
I got errors such as,
fatal error C1083: Cannot open include file: 'iostream': No such file or directory
As stated in this link, I checked out for libcmtd.lib and it is in the $(VCInstallDir)lib. It is also included in Tools | Options | Projects and Solutions | VC++ Directories | Show Directories For -> Library files.
Based on this link, I checked the precompiled header settings. I found the following there:
Precompiled Files : Yes
Precompiled Header File Name : StdAfx.pch
Precompiled Header Object File Name : StdAfx.obj
Precompiled Header Options : (blank)
Precompiled Header Source File Name : StdAfx.h
How do I disable this? In case if I disable this, won't I get any other problems for the other part of the project?
Update:
For a C program,
#include<stdio.h>
int main()
{
printf("\nHello World\n");
return 0;
}
I got the following errors,
error LNK2019: unresolved external symbol _WinMain referenced in function _WinMainCRTStartupHelper
fatal error LNK1120: 1 unresolved externals
fatal error U1077: 'D:\WINCE700\sdk\bin\i386\x86\link.EXE' : return code '0x460'
What may be the linking problem here also?
The C code that you wrote, will not work in a WinCE app. The entry point for your WinCE app is WinMain, not regular main.
All that iostream stuff is from the STL. From my own experience there are some differences in how the STL is actually implemented on WinCE versus on Windows Desktop. That will be the source of issues now and in the future. Here's an SO article discussing these problems.
Here is how you might do it in WinCE (code not actually tested)
#include "stdafx.h"
using namespace std;
#include <iostream>
int WINAPI WinMain (
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow)
{
cout << "hello world" << endl;
return 0;
}
A Windows Application and a WinCE application follows different rules and needs different libraries than a console (CRT) app. In your Visual Studio, create a default Win32 project and create a default console app. Then compare the project files between all three in a text compare tool. You'll see many differences. These differences include at least the following:
A different entry point -- WinMain, _WinMain, _tWinMain, etc
They enable use of the windows.h file and all the related apparatus
A different set of default .lib files you must link to
Despite all of this, WinCE apps get fun when you get into the GUI stuff. If I were you, I'd get out of this C++ stuff and get into the C# Compact Framework.
When you want to write a main(argc, argv) style program you must choose console application in the project wizard.
It's not possible to use cout or printf statements in these kind of WinCE applications as 010110110101 said.
Instead, for displaying text, we shall use DEBUGMSG or RETAILMSG based on the build mode.
DEBUGMSG(TRUE,(TEXT("Hello World")));
RETAILMSG(TRUE,(TEXT("Hello World")));
For example, DEBUGMSG won't work in Release mode. The syntax for these messages is in this link.

compiling FMOD with mingw?

I have the following example from gamedev, and I was wondering how you would go about compiling this. I've downloaded FMOD and its installed in C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32. And I have the .dll's and a mp3 file in my working directory but I'm not sure what/how to compile and link this through command line?
EDIT: code
#include
#include "inc/fmod.h"
FSOUND_SAMPLE* handle;
int main ()
{
// init FMOD sound system
FSOUND_Init (44100, 32, 0);
// load and play sample
handle=FSOUND_Sample_Load (0,"sample.mp3",0, 0, 0);
FSOUND_PlaySound (0,handle);
// wait until the users hits a key to end the app
while (!_kbhit())
{
}
// clean up
FSOUND_Sample_Free (handle);
FSOUND_Close();
}
That code is for FMOD3, I would recommend getting the latest release of FMODEx aka FMOD4 from www.fmod.org.
When compiling really don't have to do anything special, just ensure you '-I' include the directory that contains "inc/fmod.h" and '-L' the "lib" directory that contains the fmod lib and lastly '-l' the actual fmod lib.

Resources