G++ compile question, linking a .lib file

Joined
Jan 2, 2008
Messages
2
Reaction score
0
Hi guys,

I'm trying to do a school project. The one that I'm working on involves using a USB device. The manufacture, provided with some of the following files

GoIO_DLL.dll
GoIO_DLL.lib
GoIO_DLL_interface.h
GoIO_DLL_interface.cpp
+ some more...

Here is a small part of the .h file.

Code:
#ifndef _GOIO_DLL_INTERFACE_H_
#define _GOIO_DLL_INTERFACE_H_

/***************************************************************************************************************************
	This file documents the 'C' interface to GoIO_DLL.

	This library is implemented as GoIO_DLL.dll on Windows and as libGoIO_DLL.dylib on the Mac.
	
***************************************************************************************************************************/
#ifdef __cplusplus
	#define GOIO_DLL_INTERFACE_DECL extern "C"
#else
	#define GOIO_DLL_INTERFACE_DECL
#endif

#include "GSkipCommExt.h"
#include "GSensorDDSMem.h"
#include "GVernierUSB.h"

#ifdef TARGET_OS_MAC
	#define GOIO_MAX_SIZE_DEVICE_NAME 255
#else
	#define GOIO_MAX_SIZE_DEVICE_NAME 260
#endif

typedef void *GOIO_SENSOR_HANDLE;
typedef double gtype_real64;
typedef float gtype_real32;
typedef short gtype_int16;
typedef unsigned short gtype_uint16;
typedef int gtype_int32;

#define SKIP_TIMEOUT_MS_DEFAULT 1000
#define SKIP_TIMEOUT_MS_READ_DDSMEMBLOCK 2000
#define SKIP_TIMEOUT_MS_WRITE_DDSMEMBLOCK 4000

/***************************************************************************************************************************
	Function Name: GoIO_Init()
	
	Purpose:	Call GoIO_Init() once before making any other GoIO function calls.
				GoIO_Init() and GoIO_Uninit() should be called from the same thread.

				This routine attempts to grab the mutex that controls access to Vernier
				sensors. If Logger Pro, Logger Lite, or another GoIO application is currently
				running, then this routine will fail to grab the device control mutex, so it
				will return -1. Subsequent calls to GoIO functions will also fail until
				the application is able to run GoIO_Init() successfully.

	Return:		0 iff successful, else -1.

****************************************************************************************************************************/
GOIO_DLL_INTERFACE_DECL gtype_int32 GoIO_Init();

so i'm trying to write my own program and use this lib file and all the functions so I can access the USB device, but i'm having problem referencing the lib files..

i'm using g++ compiler which can be found here http://www.claremontmckenna.edu/math/ALee/g++/g++.html


I've haveing problem referencing the GoIO_init function.


Code:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GoIO_DLL_interface.h"

#pragma link  "GoIO_DLL.lib" // NOT SURE IF THIS IS RIGHT!!!

int main ( int arc, char *argv[])
{

if (GoIO_Init()==0){
	printf("INIT SUCCESS\n");
}

	return 0;
}

i'm not sure how to link the lib files together with my program and everything. Should it be done in the main.c file, or part of the compile instruction? how do I do it?


C:\Documents and Settings\USER1\Desktop\Vernier\design project>g++ program.c -o program
C:\DOCUME~1\USER1\LOCALS~1\Temp\ccM9PkSq.o(.text+0x19):program.cc: undefined reference to `GoIO_Init'
collect2: ld returned 1 exit status

then tried the following:

C:\Documents and Settings\USER1\Desktop\Vernier\design project>g++ -o program program.c -lGoIO_DLL -L./
/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/bin/ld: cannot open -lGoIO_DLL: No such file or directory
collect2: ld returned 1 exit status

I copied both the dll and the lib folder into that bin/ld folder that it's looking for, but i still get the same problem


Thanks for the help
 
Joined
Jan 2, 2008
Messages
2
Reaction score
0
problem solved... it was the g++ compiler...
after installing another one, it works perfectly fine

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top