Can I port RetroArch to Native Client [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I've been cutting my teeth on another coding project, and figured that the best thing that I could try is to port RetroArch all in one Emulator into Native Client, so that it could very well be a packaged app with cloud saves entirely within a browser. Look up the project on Github since I don't have enough links.
The way RetroArch is built on linux is to run a configure script, then make, then sudo make install. Altering the configure agent to select the Native Client compilers, I was able to get a couple seconds into the build when this happened,
http://pastebin.com/0WtrY6aU
using this custom Makefile here.
http://pastebin.com/iv6RmQVr
I figure it's gonna be a long hard road building and debugging this puppy, but where do you recommend I get started?

You're starting from a good place, you've just hit your first compile error.
Here it is:
In file included from settings.c:23:
input/input_common.h:73: error: redefinition of typedef ‘rarch_joypad_driver_t’
driver.h:327: note: previous declaration of ‘rarch_joypad_driver_t’ was here
Here is an excerpt from input_common.h:
typedef struct rarch_joypad_driver
{
...
} rarch_joypad_driver_t;
Here is an excerpt from driver.h:
typedef struct rarch_joypad_driver rarch_joypad_driver_t;
Just as the error says, the typedef is being redefined. I ran a test using gcc 4.6.3 from Ubuntu 12.04:
typedef struct foo { int bar; } foo_t;
typedef struct foo foo_t;
int main() { return 0; }
This compiles and links fine. The same code compiled with x86_64-nacl-gcc (which is using gcc 4.4.3), gives the following error:
typedef.c:2: error: redefinition of typedef ‘foo_t’
typedef.c:1: note: previous declaration of ‘foo_t’ was here
It seems that this error has been relaxed in more recent versions of gcc. I did some searching and found this stackoverflow link: Why "Redefinition of typedef" error with GCC 4.3 but not GCC 4.6?.
It's worth noting that x86_64-nacl-g++ will compile this code unmodified. Here are two things to try:
Compile with CC using x86_64-nacl-g++ instead of x86_64-nacl-gcc
ifdef out the definition in driver.h, and replace the other use in that file with struct rarch_joypad_driver.
For #2, you can use the following:
#ifndef __native_client__
...
#endif
Good luck, there likely will be more compile failures to fix. :)

Related

C++ code compiles with Rcpp on Mac but not Windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
This post was edited and submitted for review 15 hours ago.
Improve this question
I'm working on an R software package involving C++ code written by someone else, and on my Mac everything loads and works properly. However, when I migrate the same code to Windows, everything breaks during compilation. I have received two suggestions on how to fix the problem:
In the C++ package it says that I need to add certain CFLAGS to their Makefile to run on Windows, however I don't have a Makefile in my src folder and everything still works on Mac.. is there a proper way to add CFLAGS for Rcpp to run on Windows? Do I need to add a Makefile.win?
The C++ package calls another C++ package (in its external directory) which has compiled Windows binaries in a .vcproj file (besides their actual C++ code). Should this file be included in my src directory for Rcpp to use on Windows?
Thanks!!
Edit: The types of error messages I'm getting on Windows are in two main flavours:
undefined reference to varname (some examples of varname were Rf_xlength, std::basic_streambuf<char, std::char_traits<char> >::seekpos(std::fpos<int>, std::_Ios_Openmode), __imp_R_NilValue, REprintf and __imp__Z11annAllocPtsii.
statements like int figtreeEvaluateDirectTree(int, int, int, double*, double, double*, double*, double, double*) declared without dllimport attribute after being referenced with dll linkage.

How do I make intel TBB libraries available on Xeon Phi [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to use Intel TBB in a segment of Xeon Phi offload code. The code fails to compile with error error : *MIC* cannot open source file "tbb\parallel_for.h"
I have the MPSS stack installed, I ran the binutils.msi utility, and my includes at the top of the offloaded code file is as follows:
#include <offload.h>
#pragma offload_attribute(push, target(mic))
#include <tbb\parallel_for.h>
#pragma offload_attribute(pop)
//other includes and code follows
Why does this fail?
What do I need to change to offload and run my code sucessfully?
EDIT :
After adding the -tbb option to the "Additional Options for MIC Offload Compiler" the compiler has found the <tbb\parallel_for.h> file however it gives several warnings and errors about tbb library code not being marked shared. follows is my offloaded code segment.
#pragma offload target(mic:0) in(nums) out(results)
tbb::parallel_for<int>(0,ARRAY_SIZE,1,[&](int i)
{
results[i] = findZero(nums[i]);
});
The offload compiler basically consists of two (very) different compilers called separately on the same code. Each of them generally has its own command line, include, and library paths; and not all the command line options translated from host to the MIC compiler. In case of TBB, compiler has special option /Qtbb or just -tbb which takes care of all the paths for both compilers.
Please refer to tbb\examples\GettingStarted\SUB_STRING_FINDER\sub_string_finder_extended.cpp for how to use TBB from offload region. And check out the Makefile for how to build the example.
In order to run the code from MSVC environment, you need to setup the same environment as for Intel Compiler used to build the GettingStarted\Sub_string_finder example. The easy way to duplicate the environment inside MSVC is to run it from the same console window where the example works:
devenv /useenv
Or specifically, you need to set the MIC_LD_LIBRARY_PATH environment variable to point to MIC TBB binaries as shown here for other libraries.

C++ 11 auto feature [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i am new to c++ 11 . so i wore a small code using c++ 11 feature . but the compiler issues no type found error while using auto . my compiler is updated and i use osx mavericks
here's my code :
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> v(100);
for(int i=0;i<100;i++)
{
v[i]=i;
}
for(auto p=v.begin();p!=v.end();p++)
cout<<*p<<'\t';
cout<<endl;
return 0;
}
You will need to pass the -std=c++11 flag to your compiler or -std=c++0x depending on your compiler version.
If you're using gcc 4.2, chances are it doesn't have C++0x support yet.
See this page.
This answer might be of some use to you.
GCC 4.2 is ancient, but Apple don't ship a newer version.
You can either install a modern GCC from somewhere like Mac Ports
(which is probably simpler and quicker) or build it yourself following
the instructions at http://gcc.gnu.org/wiki/InstallingGCC

Dev C++ simple threading program

I created a simple program to learn how to use threading. This is the code i created
#include <iostream>
#include <stdlib.h>
#include <thread>
using namespace std;
void count_asc();
void count_desc();
int main() {
thread first(count_asc);
thread second(count_desc);
first.join();
second.join();
system("pause");
return 0;
}
void count_asc(){
int ctr;
for(ctr=1;ctr<=10;ctr++){
cout<<"First thread: "<<ctr<<endl;
}
}
void count_desc(){
int ctr;
for(ctr=10;ctr>=1;ctr--){
cout<<"Second thread: "<<ctr<<endl;
}
}
I am using Dev C++ 5.5.3. I have read other questions about this but me being a beginner in programming cannot really understand advanced instructions. When this code is compiled the following error is produced
main.cpp: In function 'int main()':
main.cpp:11:2: error: 'thread' was not declared in this scope
main.cpp:11:9: error: expected ';' before 'first'
main.cpp:12:9: error: expected ';' before 'second'
main.cpp:14:2: error: 'first' was not declared in this scope
main.cpp:15:2: error: 'second' was not declared in this scope
I have already included -std=c++11 in the c++ compiler additional command-line options in the project option of the Dev C++ but i can't still remove the errors. Can you please check what i am doing wrong? also as much as possible i dont want to start using other libraries as i am having a hard time building them(ex. boost)
The problem is most likely due to lack of support for C++11's std::thread in the build of GCC 4.7.1 included with TDM-GCC. Have a look at this question, for details. Your code compiles fine with GCC 4.8.1 (although it still has runtime errors):
http://ideone.com/oUhvi3
I would therefore suggest that to resolve your problem, you try updating to a more recent version of the compiler. According to this link and this link doing so should be a simple matter of installing the most recent version of the compiler into the folder where it currently resides, or alternatively, installing it in a new folder and updating the settings in Dev C++ to point to the new compiler.
However, since you are new to C++ (and programming in general), and therefore have no particular attachment to Dev C++, I would recommend that you instead switch to a more modern and widely used IDE. MS Visual Studio is a good bet for Windows, but there are plenty of open source and cross platform IDEs available for C++. Using an IDE which is popular is recommended for beginners, as you are much more likely to find sources of help and support online, and more likely to get answers on sites such as Stackoverflow, when you get stuck. There are tons of Stackoverflow questions relating to IDEs. Examples (from a quick Google search):
What is the good cross platform C++ IDE?
Best C++ IDE or Editor for Windows
https://stackoverflow.com/questions/535369/what-is-the-best-free-windows-c-ide-compiler

How do I compile a .cpp file on Linux? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm fairly comfortable with Linux and compiling things - I normally just follow the instructions and can manage to get myself out of trouble. This time, I was given a .cpp file by a random Internet citizen and I would really like to know how to compile it. Everything I seem to try (g++, c++, gcc) doesn't seem to work.
Anyhow, here's the file: http://pastebin.ca/2073013
Edit: Updated with verbose output from g++ file.cpp -o whatever: http://pastebin.ca/2073052
You'll need to compile it using:
g++ inputfile.cpp -o outputbinary
The file you are referring has a missing #include <cstdlib> directive, if you also include that in your file, everything shall compile fine.
The compiler is telling you that there are problems starting at line 122 in the middle of that strange FBI-CIA warning message. That message is not valid C++ code and is NOT commented out so of course it will cause compiler errors. Try removing that entire message.
Also, I agree with In silico: you should always tell us what you tried and exactly what error messages you got.
Just type the code and save it in .cpp format. then try "gcc filename.cpp" . This will create the object file. then try "./a.out" (This is the default object file name). If you want to know about gcc you can always try "man gcc"