Difficulty using Protobuf 3.2 in C++ - c++

I'm trying to use Protobuf in C++, but having trouble getting it to do anything meaningful. I'm using Visual Studio 2015.
I built the protobuf library. I'm using the latest version from github.
I have created a .proto file as such:
syntax = "proto3";
package Networking;
message Robot{
message KinematicLinkProto {
string name = 1;
float x_pos = 2;
float y_pos = 3;
float z_pos = 4;
float roll = 5;
float pitch = 6;
float yaw = 7;
float x_scale = 8;
float y_scale = 9;
float z_scale = 10;
}
repeated KinematicLinkProto links = 1;
}
I compile this, and try to add it to a project:
#include "Robot.pb.h"
int main(int argc, char **argv)
{
Networking::Robot robot_message;
return 0;
}
My linker links libprotobuf.lib. I am building it as /MD and libprotobuf is built as /MD.
For some reason, this simple program has the following two linker errors:
Error LNK2019 unresolved external symbol "private: static bool google::protobuf::io::CodedOutputStream::default_serialization_deterministic_" (?default_serialization_deterministic_#CodedOutputStream#io#protobuf#google##0_NA) referenced in function "public: virtual unsigned char * __cdecl Networking::Robot::SerializeWithCachedSizesToArray(unsigned char *)const " (?SerializeWithCachedSizesToArray#Robot#Networking##UEBAPEAEPEAE#Z)
Error LNK2019 unresolved external symbol "class google::protobuf::internal::ExplicitlyConstructed<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > google::protobuf::internal::fixed_address_empty_string" (?fixed_address_empty_string#internal#protobuf#google##3V?$ExplicitlyConstructed#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###123#A) referenced in function "protected: void __cdecl google::protobuf::internal::RepeatedPtrFieldBase::Clear<class google::protobuf::RepeatedPtrField<class Networking::Robot_KinematicLinkProto>::TypeHandler>(void)" (??$Clear#VTypeHandler#?$RepeatedPtrField#VRobot_KinematicLinkProto#Networking###protobuf#google###RepeatedPtrFieldBase#internal#protobuf#google##IEAAXXZ)
I'm very confused - this is a very simple program. What could I possibly be doing wrong?
EDIT: A colleague compiled proto 3001000. This version does seem to work. I'm curious as to what about 3002000 breaks everything.

If you are using DLL, use
#define PROTOBUF_USE_DLLS

Related

How do I configure AlgLib for VS2017?

I am compiling a alglib sample program (with a few changes):
#pragma once
# include "Source\RFLearn.h" \\appropriate header for this simple .cpp program.
# include <LinAlg.h>
# include <stdint.h>
# include <chrono> // for in-game frame clock.
int RFLearn::test_function()
{
alglib::real_2d_array a, b, c;
int n = 2000;
int i, j;
double timeneeded, flops;
// Initialize arrays
a.setlength(n, n);
b.setlength(n, n);
c.setlength(n, n);
for (i = 0; i<n; i++)
for (j = 0; j<n; j++)
{
a[i][j] = alglib::randomreal() - 0.5;
b[i][j] = alglib::randomreal() - 0.5;
c[i][j] = 0.0;
}
// Set global threading settings (applied to all ALGLIB functions);
// default is to perform serial computations, unless parallel execution
// is activated. Parallel execution tries to utilize all cores; this
// behavior can be changed with alglib::setnworkers() call.
alglib::setglobalthreading(alglib::parallel);
// Perform matrix-matrix product.
flops = 2 * pow((double)n, (double)3);
auto timer_start = std::chrono::high_resolution_clock::now();
alglib::rmatrixgemm(
n, n, n,
1.0,
a, 0, 0, 0,
b, 0, 0, 1,
0.0,
c, 0, 0);
auto timer_end = std::chrono::high_resolution_clock::now();
auto duration = timer_end - timer_start;
timeneeded = static_cast<double>(duration.count());
// Evaluate performance
printf("Performance is %.1f GFLOPS\n", (double)(1.0E-9*flops / timeneeded));
return 0;
}
I am confident linAlg is correctly linked (as well as all of its dependencies, particularly ap.h and ap.cpp) (Preferences->C++->AllOptions->Additional Include Directories -> aglib's source directory. Changing the link provides a different set of linker errors. AlgLib is a header only-library so I don't think I need to compile any library and add it in the linker.
When compiling this code I get the errors:
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: double * __thiscall alglib::real_2d_array::operator[](int)" (??Areal_2d_array#alglib##QAEPANH#Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall alglib::real_2d_array::~real_2d_array(void)" (??1real_2d_array#alglib##UAE#XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: __thiscall alglib::real_2d_array::real_2d_array(void)" (??0real_2d_array#alglib##QAE#XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::parallel" (?parallel#alglib##3ABUxparams#1#B)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::rmatrixgemm(int,int,int,double,class alglib::real_2d_array const &,int,int,int,class alglib::real_2d_array const &,int,int,int,double,class alglib::real_2d_array const &,int,int,struct alglib::xparams)" (?rmatrixgemm#alglib##YAXHHHNABVreal_2d_array#1#HHH0HHHN0HHUxparams#1##Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "double __cdecl alglib::randomreal(void)" (?randomreal#alglib##YANXZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: void __thiscall alglib::ae_matrix_wrapper::setlength(int,int)" (?setlength#ae_matrix_wrapper#alglib##QAEXHH#Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::setglobalthreading(struct alglib::xparams)" (?setglobalthreading#alglib##YAXUxparams#1##Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::xdefault" (?xdefault#alglib##3ABUxparams#1#B)
I intuit that the problem lies around here: http://www.alglib.net/translator/man/manual.cpp.html#gs_configuring
but I cannot make heads or tails of it. What's the next step?
I had a similar (not exact) problem and it went away just by adding the compiled the cpp files to my project and set "included in the project" to true.

Unable to link with libx264.lib static library

I'm building custom video encoder using x264 as a static library. I've followed this guide in order to build static library. Trying to compile this:
x264_t * setup_encoder(int width, int height){
x264_param_t param;
x264_param_default_preset(&param, "veryfast", "zerolatency");
param.i_threads = 1;
param.i_width = width;
param.i_height = height;
param.i_fps_num = 26;
param.i_fps_den = 1;
// Intra refres:
param.i_keyint_max = 26;
param.b_intra_refresh = 1;
//Rate control:
param.rc.i_rc_method = X264_RC_CRF;
param.rc.f_rf_constant = 25;
param.rc.f_rf_constant = 25;
param.rc.f_rf_constant_max = 35;
//For streaming:
param.b_repeat_headers = 1;
param.b_annexb = 1;
x264_param_apply_profile(&param, "baseline");
return x264_encoder_open(&param);
}
Results in:
main.obj : error LNK2019: unresolved external symbol "int __cdecl x264_param_default_preset(struct x264_param_t *,char const *,char const *)"
main.obj : error LNK2019: unresolved external symbol "int __cdecl x264_param_apply_profile(struct x264_param_t *,char const *)"
main.obj : error LNK2019: unresolved external symbol "struct x264_t * __cdecl x264_encoder_open_136(struct x264_param_t *)"
%PROJECT_DIR%: fatal error LNK1120: 3 unresolved externals
Linker scans libx264.lib, but can't find anything inside.
Searching .\lib\libx264.lib:
With dumpbin /HEADERS I can actually find the declaration I need, but linker is unable to do it.
SECTION HEADER #38
.text name
0 physical address
0 virtual address
E60 size of raw data
930C file pointer to raw data (0000930C to 0000A16B)
D219 file pointer to relocation table
0 file pointer to line numbers
40 number of relocations
0 number of line numbers
60501020 flags
Code
COMDAT; sym= x264_param_default_preset
16 byte align
Execute Read
Enviroment is Visual Studio 2012 with Intel Compiler 14 on Windows 8 64-bit.
try including using C style bindings.
extern "C" {
#include <x264.h>
}

error LNK2019: unresolved external symbol

I'm fresh in c++ and I'm facing a problem in including C++ code in Matlab C Mex-file.
I have 5 files: RTIFederate.h, RTIFederate.cpp, RTIFedAmb.cpp, RTIFedAmb.h, RTI3.cpp. RTI3.cpp contains the MEX modules. I'm getting the following errors while compiling with MEX command and libraries:
Creating library C:\Users\Nudel\AppData\Local\Temp\mex_DBx_sv\templib.x and object
C:\Users\Nudel\AppData\Local\Temp\mex_DBx_sv\templib.exp
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::ObjectInstanceHandle DistributedParametersLine" (?DistributedParametersLine##3VObjectInstanceHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * IEC_Model" (?IEC_Model##3PAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * IEC_Attribute" (?IEC_Attribute##3PAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::ObjectInstanceHandle PowerResource" (?PowerResource##3VObjectInstanceHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::AttributeHandle * _classattribute" (?_classattribute##3PAVAttributeHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "public: __thiscall RTIFedAmb::RTIFedAmb(void)" (??0RTIFedAmb##QAE#XZ) referenced in function "public: void __thiscall RTIFederate::run(void)" (?run#RTIFederate##QAEXXZ)
RTI3.mexw32 : fatal error LNK1120: 6 unresolved externals
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'RTI3.mexw32' failed
My RTI3.cpp has the following piece of code:
#include "RTIFederate.cpp"
static void mdlOutputs(SimStruct *S, int_T tid)
{
RTIFederate *c = (RTIFederate*) ssGetPWork(S)[0];
// LĂȘ a porta de entrada correspondente
time_T offset = ssGetOffsetTime(S,0);
time_T timeOfNextHit = ssGetT(S) + offset ;
ssSetTNext(S, timeOfNextHit);
for(int_T i=0;i<NUM_INPUTS;i++) {
int *dims = ssGetInputPortDimensions(S, i);
int frameSize = dims[0]; // Tamanho do campo (se for trifasico sera 3 , por ex
int numChannels = dims[1];
if((ssGetInputPortWidth(S,i)<1) ||(ssGetInputPortWidth(S,i)>1)|| (frameSize>1)) {
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S, i);
real_T *y = ssGetOutputPortRealSignal(S,i);
int_T width = ssGetOutputPortWidth(S,i);
mexPrintf("%s%d%s%s%d\n","Num da entrada ->",i," ","Num largura > ",width);
for (int_T j=0;j<width;j++){
*y++ =*uPtrs[j];
mexPrintf("%s%u%s\n","IEC_Model[",i,"]--",IEC_Attribute[i].c_str());
if(IEC_Model[i].compare("DistributedParametersLine")!=0) {
if(IEC_Attribute[i].compare("Voltage")) {
mexPrintf("%s%u%s%f\n","Voltage[",j,"]-->",*uPtrs[j]);
c->AtualizaValoresdeAtributos(DistributedParametersLine,_classattribute[0],*uPtrs[j],timeOfNextHit);
} else if(IEC_Attribute[i].compare("Current")) {
mexPrintf("%s%u%s%f\n","Current[",j,"]-->",*uPtrs[j]);
c->AtualizaValoresdeAtributos(DistributedParametersLine,_classattribute[0],*uPtrs[j],timeOfNextHit);
}
} // end if IEC_Model
mexPrintf("%s%f\n","Avanco de tempo1->",timeOfNextHit);
} // end for
} else {
double *u1=(double *) ssGetInputPortSignal(S, i);
real_T *y1 = ssGetOutputPortRealSignal(S,i);
(*y1) =(*u1); //copia entrada para saida
mexPrintf("%s%f\n","Avanco de tempo2->",timeOfNextHit);
c->AtualizaValoresdeAtributos(PowerResource,_classattribute[0],*u1,timeOfNextHit);
} // end else
} // end for i
}
/* Function: mdlTerminate */
static void mdlStart(SimStruct *S)
{
char *buf;
size_t buflen;
int status;
buflen = mxGetN((ssGetSFcnParam(S, 2)))*sizeof(mxChar)+1 ; // read 3rd param
buf = (char *)mxMalloc(buflen); //alloc mem
status = mxGetString((ssGetSFcnParam(S, 2)), buf,(mwSize)buflen);
ssGetPWork(S)[0] = (void *) new RTIFederate; // store new C++ object in the
RTIFederate *c = (RTIFederate *) ssGetPWork(S)[0];
c->InterpretaArqMDL(buf); // Rotina que trata da interpretacao dos objetos da norma IEC 61968
c->run();
...
}
On top of RTIFederate.cpp I have declared the following:
#include "RTIFedAmb.h"
#include "RTIFederate.h"
and in the file RTIFederate.h I declared:
class RTIFederate
{
public:
RTIambassador *rtiamb;
RTIFedAmb *fedamb;
// variables //
ObjectClassHandle _ClassObject[300];
AttributeHandle _classattribute[300];
string IEC_Model[29],IEC_Attribute[20];//
// public methods //
RTIFederate();
virtual ~RTIFederate();
...
}
extern ObjectClassHandle _ClassObject[300];
extern AttributeHandle _classattribute[300];
extern AttributeHandleSet attributeSet[300];
extern ObjectInstanceHandle ProtectedSwitch,Recloser,ThreePhaseBreaker,ACLineSegment,DistributedParametersLine;
extern RTIambassador *rtiamb;
extern RTIFedAmb *fedamb;
Also there is a piece of code in RTIFedAmb.h:
//methods
RTIFedAmb();
virtual ~RTIFedAmb() throw();
Can anyone help me to explain what am I missing ?
So, you want to include c-lib in your c ++ project. That's fine but you should note one thing: c ++ differs a bit from c. And you found a good illustration.
c ++ "deforms" function names in lib while c does not. Nevertheless you still can use c libraries. Do it so:
extern "C" ObjectClassHandle _ClassObject[300];
extern "C" AttributeHandle _classattribute[300];
extern "C" AttributeHandleSet attributeSet[300];
extern "C" ObjectInstanceHandle ProtectedSwitch,Recloser,ThreePhaseBreaker,ACLineSegment,DistributedParametersLine;
extern "C" RTIambassador *rtiamb;
extern "C" RTIFedAmb *fedamb;
Hope it will help you.

MSVS2010 C++ Console Code Ported to MSVS2010 C++ GUI is Failing. Why?

I just completed a proof of concept, or so I thought, of feeding Microsoft Visual Studio 2010 some C++ code as a console program. The C++ code that compiled is given below:
#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>
#include <stdlib.h>
#include <sndfile.h>
//The following libraries are related to parsing the text files
#include <iostream> //Open the file
#include <fstream> //Reading to and from files
//The following libraries are for conducting the DTW analysis
#include "dtw.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
printf("This is a test\n");
//This will be the length of the buffer used to hold samples while the program processes them.
//A SNDFILE is like FILE in a standard C library. Consequently, the sf_open_read and sf_open_write functions will return an
//SNDFILE* pointer when they successfully open the specified file.
SNDFILE* sf = NULL;
/*SF_INFO will obtain information of the file we wish to load into our program. */
SF_INFO info;
/*The following is descriptive information to obtain from wave files. These are declarations*/
int num_channels;
double num, num_items;S
double *buf;
int f, sr, c;
int i,j;
FILE *out;
/*This is where the program will open the WAV file */
info.format = 0;
sf = sf_open("C:\\Users\\GeekyOmega\\Desktop\\gameon.wav", SFM_READ, &info);
if(sf == NULL)
{
printf("Failed to open the file.\n");
getchar();
exit(-1);
}
/*Print some file information */
f = info.frames;
sr = info.samplerate;
c = info.channels;
/*Print information related to file*/
printf("frames = %d\n",f);
printf("sample rate = %d\n",sr);
printf("channels = %d\n",c);
/*Calculate and print the number of items*/
num_items = f*c;
printf("Read %lf items\n", num_items);
/*Allocate space for the data to be read*/
buf = (double *) malloc(num_items*sizeof(double));
num = sf_read_double(sf,buf,num_items);
sf_close(sf);
/*print the information*/
printf("Read %lf items\n", num);
/*Write the data to the filedata.out*/
out = fopen("filedata.txt", "w");
for(i = 0; i < num; i+=c)
{
for(j = 0; j < c; ++j)
{
fprintf(out, "%lf ", buf[i +j]);
}
fprintf(out,"\n");
}
fclose(out);
}
So next, and this is critical, I want this to work with a GUI. That is, I load in any file I want and it converts that wav file to text. I provide that code below:
#pragma once
//Libraries required for libsndfile
#include <sndfile.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
namespace WaveGui {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Runtime::InteropServices;
using namespace std;
/// <summary>
/// Summary for Form1
/// </summary>
I edited this for readability. It was a standard MSVS2010 form. I only added a button and open file dialog.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
//Note: Ask Gustafson how we might free the memory for this strign
// http://support.microsoft.com/?id=311259
char* str2 = (char*)(void*)Marshal::StringToHGlobalAnsi(openFileDialog1->FileName);
SNDFILE* sf = NULL;
SF_INFO info;
/*The following is descriptive information to obtain from wave files. These are declarations*/
int num_channels;
double num, num_items;
double *buf;
int f, sr, c;
int i,j;
FILE *out;
/*This is where the program will open the WAV file */
info.format = 0;
sf = sf_open(str2, SFM_READ, &info);
if(sf == NULL)
{
exit(-1);
}
/*Print some file information */
f = info.frames;
sr = info.samplerate;
c = info.channels;
/*Calculate and print the number of items*/
num_items = f*c;
/*Allocate space for the data to be read*/
buf = (double *) malloc(num_items*sizeof(double));
num = sf_read_double(sf,buf,num_items);
sf_close(sf);
/*Write the data to the filedata.out*/
out = fopen("filedata.txt", "w");
for(i = 0; i < num; i+=c)
{
for(j = 0; j < c; ++j)
{
fprintf(out, "%lf ", buf[i +j]);
}
fprintf(out,"\n");
}
fclose(out);
}
}
};
}
In the code for the button, I convert from a system string to regular string and then try to use the C++ code above to convert my wave file to txt information. I know the conversion code works, and I know the button code works as I have tested them separately. However, my library sndfile.h really dies when I try to use it now.
The error it gives me when I added the libraries stdio.h, Windows.H, stdlib.h, iostream, fstream is as follows:
1>WaveGui.obj : error LNK2031: unable to generate p/invoke for "extern "C" int __clrcall sf_close(struct SNDFILE_tag *)" (?sf_close##$$J0YMHPAUSNDFILE_tag###Z); calling convention missing in metadata
1>WaveGui.obj : error LNK2031: unable to generate p/invoke for "extern "C" __int64 __clrcall sf_read_double(struct SNDFILE_tag *,double *,__int64)" (?sf_read_double##$$J0YM_JPAUSNDFILE_tag##PAN_J#Z); calling convention missing in metadata
1>WaveGui.obj : error LNK2031: unable to generate p/invoke for "extern "C" struct SNDFILE_tag * __clrcall sf_open(char const *,int,struct SF_INFO *)" (?sf_open##$$J0YMPAUSNDFILE_tag##PBDHPAUSF_INFO###Z); calling convention missing in metadata
1>WaveGui.obj : warning LNK4248: unresolved typeref token (01000027) for 'SNDFILE_tag'; image may not run
1>WaveGui.obj : error LNK2028: unresolved token (0A000022) "extern "C" int __clrcall sf_close(struct SNDFILE_tag *)" (?sf_close##$$J0YMHPAUSNDFILE_tag###Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>WaveGui.obj : error LNK2028: unresolved token (0A000023) "extern "C" __int64 __clrcall sf_read_double(struct SNDFILE_tag *,double *,__int64)" (?sf_read_double##$$J0YM_JPAUSNDFILE_tag##PAN_J#Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>WaveGui.obj : error LNK2028: unresolved token (0A000025) "extern "C" struct SNDFILE_tag * __clrcall sf_open(char const *,int,struct SF_INFO *)" (?sf_open##$$J0YMPAUSNDFILE_tag##PBDHPAUSF_INFO###Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>WaveGui.obj : error LNK2019: unresolved external symbol "extern "C" int __clrcall sf_close(struct SNDFILE_tag *)" (?sf_close##$$J0YMHPAUSNDFILE_tag###Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>WaveGui.obj : error LNK2019: unresolved external symbol "extern "C" __int64 __clrcall sf_read_double(struct SNDFILE_tag *,double *,__int64)" (?sf_read_double##$$J0YM_JPAUSNDFILE_tag##PAN_J#Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>WaveGui.obj : error LNK2019: unresolved external symbol "extern "C" struct SNDFILE_tag * __clrcall sf_open(char const *,int,struct SF_INFO *)" (?sf_open##$$J0YMPAUSNDFILE_tag##PBDHPAUSF_INFO###Z) referenced in function "private: void __clrcall WaveGui::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click#Form1#WaveGui##$$FA$AAMXP$AAVObject#System##P$AAVEventArgs#4##Z)
1>c:\users\geekyomega\documents\visual studio 2010\Projects\WaveGui\Debug\WaveGui.exe : fatal error LNK1120: 6 unresolved externals
As near as I can tell, I installed the library right. After all, it works perfectly fine with these libraries in a console situation. However, when I try to use the exact same code and libraries with my GUI form, it seems that the libraries are not playing nice with each other and as a result, I can't read my .h file right and access structs like SNDFILE.
Can someone please let me know what is going wrong? I have spent hours on this and I hope I don't have to scrap the libsndfile library. I really want to get it to work with MSVS2010, with the GUI and as far as I can tell, there is no reason this shouldn't be working. But you know what they say, computers don't lie.
As always, thanks for your patient help.
GeekyOmega
So, your console app is native code, but your GUI app is managed C++. Was that intentional, or did you intend for your GUI app to be native (Win32) code too?
I think you'll have better luck if you either go with 100% native code, or perhaps create a DLL to encapsulate your native code and call that via P/Invoke from your .NET GUI. Here's an example of using P/Invoke:
http://manski.net/2012/05/29/pinvoke-tutorial-basics-part-1/

DirectX 9 "unresolved external symbol" problem

I have been working on learning DirectX for a couple days and have run into a problem. I have been following a books example and have solved several annoying problems that have come up, but have been unsuccessful at solving my most recent one. The compiler states that I have an unresolved external symbol whenever I try to compile. Here is the error code below.
1>game.obj : error LNK2019: unresolved external symbol "struct IDirect3DSurface9 * __cdecl
LoadSurface(char *,unsigned long)" (?LoadSurface##YAPAUIDirect3DSurface9##PADK#Z) referenced in
function "int __cdecl Game_Init(struct HWND__ *)" (?Game_Init##YAHPAUHWND__###Z)
1>C:\Users\Christopher\Documents\Visual Studio 2008\Projects\Work\Debug\Work.exe : fatal error
LNK1120: 1 unresolved externals
I am running: [compiler: Visual Studios 2008] [Operating system: Windows 7 64bit professional]
Here a sample of the code and where it seem to be taking place. (I hope I gave enough info)
LPDIRECT3DSURFACE9 kitty_image[7];
SPRITE kitty;
LPDIRECT3DSURFACE9 back;
//timing variable
long start = GetTickCount();
//initializes the game
int Game_Init(HWND hwnd)
{
char s[20];
int n;
//set random number seed
srand(time(NULL));
//load the sprite animation
for (n=0; n<6; n++)
{
sprintf(s, "cat%d.bmp",n+1);
kitty_image[n] = LoadSurface(s, D3DCOLOR_XRGB(255,0,255));
if (kitty_image[n] == NULL)
return 0;
}
back = LoadSurface("background.bmp", NULL );
//initialize the sprite's properties
kitty.x = 100;
kitty.y = 150;
kitty.width = 96;
kitty.height = 96;
kitty.curframe = 0;
kitty.lastframe = 5;
kitty.animdelay = 2;
kitty.animcount = 0;
kitty.movex = 8;
kitty.movey = 0;
//return okay
return 1;
}
I have linked both d3d9.lib and d3dx9.lib to my project and have included all neccesary header files that I know of (d3d9.h, d3dx9.h). Any help is greatly appreciated! Thanks in advance!!!
It looks like the linker is complaining that there is no such function LoadSurface. Where did you define it?