Re: problems when building Breve plugin
Naiqi Weng <[email protected]> Wed, 26 Jan 2005 20:14:48 -0800 (PST)
| Newsgroups | gmane.comp.breve |
|---|---|
| Message-ID | <[email protected]> |
Hi, Ian Sorry for my late reply. I have been tried to find where the problem is but still can't find it. I have attached my code and I am really sorry if it takes too much of your time. I really appreciate your help. The breveViconRTClient.cpp is my plugin file. It calls a function in ViconRTClient.cpp, ViconRTClient.cpp uses some class defined in ClientCodes.h. My makefile is as follows: BREVEPATH=../../bin/breve all: make -f Makefile `uname` export objects: ClientCodes.o ViconRTClient.o breveViconRTClient.o MINGW32_NT-5.0: make objects 'DEFINES=-DWINDOWS' dlltool -z breveViconRTClient.def breveViconRTClient.o $(LD) --allow-multiple-definition -shared -o breveViconRTClient_plugin.o breveViconRTClient.o breveViconRTClient.def ViconRTClient.o ClientCodes.o $(BREVEPATH).exe -lgcc -lm -lws2_32 -lstdc++ .c.o: $(CC) -G $(DEFINES) -c $*.c -I.. .cpp.o: $(CXX) $(DEFINES) -c $*.cpp -I.. clean: -rm *.o I am using MinGW 3.1.0 and the gcc version is 3.2.3. You mentioned in your last email that the $(BREVEPATH).exe is not necessary, I don't know, I just guess because I am compiling the plugin for Breve, so should include the breve.exe when linking. Actually my makefile is almost a copy of the breve plugin examples in Breve 1.9 distribution. Thanks a lot!!! Best regards Naiqi Ian Lindsay <[email protected]> wrote: On Fri, Jan 21, 2005 at 02:08:02PM -0800, Naiqi Weng wrote: > $(LD) --allow-multiple-definition -shared -o breveViconRTClient_plugin.o breveViconRTClient.o breveViconRTClient.def ViconRTClient.o ClientCodes.o $(BREVEPATH).exe -lgcc -lm -lws2_32 -lstdc++ > > "/mingw/lib/libstdc++.a(stl-inst.o)(.text$_ZNSt24__default_alloc_templateILb1ELi0EE5_LockC2Ev+0x2b): undefined reference to `__gthr_win32_mutex_lock' ....." I'm unable to reproduced this on MinGW (although I did manage to crash the linker once). Maybe you could provide a minimal source file that fails to link in this way. Also, I wonder about the "$(BREVEPATH).exe" .. is that really necessary? _______________________________________________ breve mailing list [email protected] http://lists.spiderland.org/mailman/listinfo/breve --------------------------------- Do you Yahoo!? Yahoo! Search presents - Jib Jab's 'Second Term' _______________________________________________ breve mailing list [email protected] http://lists.spiderland.org/mailman/listinfo/breve
breveViconRTClient.cpp
(text/plain, 898 B)
#include "slBrevePluginAPI.h"
// we include this to define ViconRTClient class:
#include "ViconRTClient.h"
extern "C" void breveViconRTClientLoadFunctions(void *data);
int breveViconRTClient_initialize(stEval args[], stEval *target, void *i); // will call: int initialize(char* server_ip_addr);
#ifdef WINDOWS
asm(".section .drectve");
asm(".ascii \"-export:breveViconRTClientLoadFunctions\"");
#endif /* WINDOWS */
// int initialize(char* server_ip_addr);
int breveViconRTClient_initialize(stEval args[], stEval *target, void *i) {
ViconRTClient *viconClientInstance = (ViconRTClient*)STPOINTER(&args[0]);
STINT(target) = viconClientInstance->initialize(STSTRING(&args[1]));
return EC_OK;
}
extern "C" void breveViconRTClientLoadFunctions(void *data) {
stNewSteveCall(data, "breveViconRTClient_initialize", breveViconRTClient_initialize, AT_NULL, AT_POINTER, AT_STRING, 0);
}
ClientCodes.cpp
(text/plain, 361 B)
//----------------------------------------------------------------------------- // ClientCodes //----------------------------------------------------------------------------- #include "ClientCodes.h" const std::vector< std::string > ClientCodes::MarkerTokens = MakeMarkerTokens(); const std::vector< std::string > ClientCodes::BodyTokens = MakeBodyTokens();
ClientCodes.h
(text/plain, 3.7 KB)
//-----------------------------------------------------------------------------
// ClientCodes
//-----------------------------------------------------------------------------
#pragma once
#include <string>
#include <vector>
#include <functional>
#include "assert.h"
class ClientCodes
{
public:
enum EType
{
ERequest,
EReply
};
enum EPacket
{
EClose,
EInfo,
EData,
EStreamOn,
EStreamOff
};
static const std::vector< std::string > MarkerTokens;
static const std::vector< std::string > BodyTokens;
static std::vector< std::string > MakeMarkerTokens()
{
std::vector< std::string > v;
v.push_back("<P-X>");
v.push_back("<P-Y>");
v.push_back("<P-Z>");
v.push_back("<P-O>");
return v;
}
static std::vector< std::string > MakeBodyTokens()
{
std::vector< std::string > v;
v.push_back("<A-X>");
v.push_back("<A-Y>");
v.push_back("<A-Z>");
v.push_back("<T-X>");
v.push_back("<T-Y>");
v.push_back("<T-Z>");
return v;
}
struct CompareNames : std::binary_function<std::string, std::string, bool>
{
bool operator()(const std::string & a_S1, const std::string & a_S2) const
{
std::string::const_iterator iS1 = a_S1.begin();
std::string::const_iterator iS2 = a_S2.begin();
while(iS1 != a_S1.end() && iS2 != a_S2.end())
// if(std::toupper(*(iS1++)) != std::toupper(*(iS2++))) return false;
return a_S1.size() == a_S2.size();
}
};
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class MarkerChannel
{
public:
std::string Name;
int X;
int Y;
int Z;
int O;
MarkerChannel(std::string & a_rName) : X(-1), Y(-1), Z(-1), O(-1), Name(a_rName) {}
int & operator[](int i)
{
switch(i)
{
case 0: return X;
case 1: return Y;
case 2: return Z;
case 3: return O;
default: assert(false); return O;
}
}
int operator[](int i) const
{
switch(i)
{
case 0: return X;
case 1: return Y;
case 2: return Z;
case 3: return O;
default: assert(false); return -1;
}
}
bool operator==(const std::string & a_rName)
{
std::string::const_iterator iS1 = Name.begin();
std::string::const_iterator iS2 = a_rName.begin();
while(iS1 != Name.end() && iS2 != a_rName.end())
// if(std::toupper(*(iS1++)) != std::toupper(*(iS2++))) return false;
return Name.size() == a_rName.size();
}
};
class MarkerData
{
public:
double X;
double Y;
double Z;
bool Visible;
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class BodyChannel
{
public:
std::string Name;
int TX;
int TY;
int TZ;
int RX;
int RY;
int RZ;
BodyChannel(std::string & a_rName) : RX(-1), RY(-1), RZ(-1), TX(-1), TY(-1), TZ(-1), Name(a_rName) {}
int & operator[](int i)
{
switch(i)
{
case 0: return RX;
case 1: return RY;
case 2: return RZ;
case 3: return TX;
case 4: return TY;
case 5: return TZ;
default: assert(false); return TZ;
}
}
int operator[](int i) const
{
switch(i)
{
case 0: return RX;
case 1: return RY;
case 2: return RZ;
case 3: return TX;
case 4: return TY;
case 5: return TZ;
default: assert(false); return -1;
}
}
bool operator==(const std::string & a_rName)
{
std::string::const_iterator iS1 = Name.begin();
std::string::const_iterator iS2 = a_rName.begin();
while(iS1 != Name.end() && iS2 != a_rName.end())
// if(std::toupper(*(iS1++)) != std::toupper(*(iS2++))) return false;
return Name.size() == a_rName.size();
}
};
class BodyData
{
public:
// Representation of body translation
double TX;
double TY;
double TZ;
// Representation of body rotation
// Quaternion
double QX;
double QY;
double QZ;
double QW;
// Global rotation matrix
double GlobalRotation[3][3];
double EulerX;
double EulerY;
double EulerZ;
};
ViconRTClient.cpp
(text/plain, 1.8 KB)
#include "ViconRTClient.h"
int ViconRTClient::initialize(char* server_ip_addr) {
#ifdef VC_VERBOSE
std::cout << "ViconRTClient: Initializing Winsock" << std::endl;
#endif VC_VERBOSE
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 2, 0 );
if(WSAStartup( wVersionRequested, &wsaData ) != 0)
{
std::cout << "ViconRTClient: Socket Initialization Error" << std::endl;
return 1;
}
// Create Socket
SocketHandle = INVALID_SOCKET;
struct protoent* pProtocolInfoEntry;
char* protocol;
int type;
protocol = "tcp";
type = SOCK_STREAM;
pProtocolInfoEntry = getprotobyname(protocol);
assert(pProtocolInfoEntry);
if(pProtocolInfoEntry)
SocketHandle = socket(PF_INET, type, pProtocolInfoEntry->p_proto);
if(SocketHandle == INVALID_SOCKET)
{
std::cout << "ViconRTClient: Socket Creation Error" << std::endl;
return 1;
}
#ifdef VC_VERBOSE
std::cout << "ViconRTClient: Initializing Socket Connection to " << server_ip_addr << std::endl;
#endif VC_VERBOSE
// Find Endpoint
struct hostent* pHostInfoEntry;
struct sockaddr_in Endpoint;
static const int port = 800;
memset(&Endpoint, 0, sizeof(Endpoint));
Endpoint.sin_family = AF_INET;
Endpoint.sin_port = htons(port);
pHostInfoEntry = gethostbyname(server_ip_addr);
if(pHostInfoEntry)
memcpy(&Endpoint.sin_addr, pHostInfoEntry->h_addr,
pHostInfoEntry->h_length);
else
Endpoint.sin_addr.s_addr = inet_addr(server_ip_addr);
if(Endpoint.sin_addr.s_addr == INADDR_NONE)
{
std::cout << "ViconRTClient: Bad Address" << std::endl;
return 1;
}
// Create Socket
int result = connect( SocketHandle, (struct sockaddr*) & Endpoint, sizeof(Endpoint));
if(result == SOCKET_ERROR)
{
std::cout << "ViconRTClient: Failed to create Socket" << std::endl;
int e = WSAGetLastError();
return 1;
}
return 0;
}
ViconRTClient.h
(text/plain, 1 KB)
//-----------------------------------------------------------------------------
// Vicon RT Client
//-----------------------------------------------------------------------------
#pragma once
#include <iostream>
//#include <cassert>
#include "assert.h"
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits>
#include <math.h>
#include <winsock2.h>
#include "ClientCodes.h"
using namespace std;
const int VERBOSE = 1;
const int BRIEF = 0;
#define PR(x) cout << #x"=" << x << endl;
//#define VC_VERBOSE
class ViconRTClient {
public:
ViconRTClient(void) {};
~ViconRTClient(void) {};
int initialize(char* server_ip_addr);
private:
std::vector< std::string > info;
std::vector< MarkerChannel > MarkerChannels;
std::vector< MarkerData > markerPositions;
std::vector< BodyData > bodyPositions;
std::vector< BodyChannel > BodyChannels;
int FrameChannel;
//static const int bufferSize = 2040;
char buff[2040];
char * pBuff;
SOCKET SocketHandle;
long int size;
};