athanasios
Posts: 5
Joined: Mon Jun 10, 2019 5:53 pm

Porting C++ code to the Raspberry Pi

Tue Jun 11, 2019 5:33 pm

Hello everyone.

I am trying to port a program originally compiled in Windows to the Raspberry Pi 3 model B+, running Raspbian. I understand the basics in Linux and was able to compile and run "Hello world", but have no real experience with C++ or the Raspberry Pi.

The source code I need to compile is meant to read data packets arriving at the Pi's Ethernet port from a data acquisition board. I am trying to compile this using Geany, and get lot's of errors, see compiler output appended below.

Can someone help me in any way resolve these errors?

+++++++++++++++++++++++++++++++++++++++++++++++++++++++


In file included from Multiplicity.cpp:5:0:
DetectorParameters.h:43:2: error: ‘CStringA’ does not name a type
CStringA BoatDataIP;
^~~~~~~~
Multiplicity.cpp:290:55: error: expected ‘,’ or ‘...’ before ‘mult_array_in’
void Multiplicity::update_prob_array(unsigned __int64 mult_array_in[], double prob_array_out[], int len)
^~~~~~~~~~~~~
Multiplicity.cpp:290:6: error: prototype for ‘void Multiplicity::update_prob_array(unsigned int)’ does not match any in class ‘Multiplicity’
void Multiplicity::update_prob_array(unsigned __int64 mult_array_in[], double prob_array_out[], int len)
^~~~~~~~~~~~
In file included from Multiplicity.cpp:4:0:
Multiplicity.h:68:7: error: candidate is: void Multiplicity::update_prob_array(long long unsigned int*, double*, int)
void update_prob_array(unsigned long long mult_array_in[], double prob_array_out[], int len);
^~~~~~~~~~~~~~~~~
Multiplicity.cpp: In member function ‘void Multiplicity::display_mult(double)’:
Multiplicity.cpp:419:2: error: ‘CString’ was not declared in this scope
CString str;
^~~~~~~
Multiplicity.cpp:421:10: error: expected ‘;’ before ‘msg’
CString msg=L"Multiplicity Distributions @ Collection Time = ";
^~~
Multiplicity.cpp:424:2: error: ‘str’ was not declared in this scope
str.Format(L"%.1f sec\n\n",time);
^~~
Multiplicity.cpp:425:2: error: ‘msg’ was not declared in this scope
msg += str;
^~~
Multiplicity.cpp:436:3: error: ‘__int64’ was not declared in this scope
__int64 r_plus_a = this->mult_dist_ra;
^~~~~~~
Multiplicity.cpp:437:11: error: expected ‘;’ before ‘a’
__int64 a = this->mult_dist_a;
^
Multiplicity.cpp:439:31: error: ‘r_plus_a’ was not declared in this scope
str.Format(L"%d \t\t%ld",i, r_plus_a);
^~~~~~~~
Multiplicity.cpp:441:27: error: ‘a’ was not declared in this scope
str.Format(L"\t\t%ld\n",a);
^
Multiplicity.cpp:462:23: error: ‘MB_OK’ was not declared in this scope
if(AfxMessageBox(msg,MB_OK|MB_ICONINFORMATION))
^~~~~
Multiplicity.cpp:462:29: error: ‘MB_ICONINFORMATION’ was not declared in this scope
if(AfxMessageBox(msg,MB_OK|MB_ICONINFORMATION))
^~~~~~~~~~~~~~~~~~
Multiplicity.cpp:462:47: error: ‘AfxMessageBox’ was not declared in this scope
if(AfxMessageBox(msg,MB_OK|MB_ICONINFORMATION))
^
Multiplicity.cpp: At global scope:
Multiplicity.cpp:471:61: error: expected ‘,’ or ‘...’ before ‘arr’
int Multiplicity::get_effective_array_size(unsigned __int64 arr[], int max_len)
^~~
Multiplicity.cpp:471:5: error: prototype for ‘int Multiplicity::get_effective_array_size(unsigned int)’ does not match any in class ‘Multiplicity’
int Multiplicity::get_effective_array_size(unsigned __int64 arr[], int max_len)
^~~~~~~~~~~~
In file included from Multiplicity.cpp:4:0:
Multiplicity.h:82:6: error: candidate is: int Multiplicity::get_effective_array_size(long long unsigned int*, int)
int get_effective_array_size(unsigned long long arr[], int max_len);
^~~~~~~~~~~~~~~~~~~~~~~~

markkuk
Posts: 130
Joined: Thu Mar 22, 2018 1:02 pm
Location: Finland

Re: Porting C++ code to the Raspberry Pi

Tue Jun 11, 2019 9:29 pm

The code you are trying to compile is written for Microsoft Windows and the Microsoft Visual C++ compiler. All the errors are from types and funtions that are specific to the Microsoft environment and not parts of the standard C++ language. You need to remove all Windows-specific code and write equivalent code that works in Linux.

athanasios
Posts: 5
Joined: Mon Jun 10, 2019 5:53 pm

Re: Porting C++ code to the Raspberry Pi

Thu Jun 13, 2019 12:41 pm

OK, thank you, this makes sense.

athanasios
Posts: 5
Joined: Mon Jun 10, 2019 5:53 pm

Re: Porting C++ code to the Raspberry Pi

Thu Jun 13, 2019 4:41 pm

Markkuk,

Would you be interested in consulting for us on this matter?

Heater
Posts: 13600
Joined: Tue Jul 17, 2012 3:02 pm

Re: Porting C++ code to the Raspberry Pi

Thu Jun 13, 2019 5:01 pm

Wine is not an emulator might help: https://www.winehq.org

Wine is normally used to run Windows applications on Intel x86 PC's running Linux.

But wine comes with a library, libwine, that provides Windows API. That means you can compile your Windows program on Linux. Provided it does not use any API functions that libwine does not support it should work.

I have done this some years ago. As an experiment I wrote a simple win32 application with dialog boxes, text inputs, buttons etc. I compiled it with Wine on Linux. It worked very well.

I have no idea if this will also work on a Raspberry Pi but it might be worth a try.
Memory in C++ is a leaky abstraction .

athanasios
Posts: 5
Joined: Mon Jun 10, 2019 5:53 pm

Re: Porting C++ code to the Raspberry Pi

Thu Jun 13, 2019 5:05 pm

Ok, thank you Heater.

Return to “C/C++”