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

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.

Related

Linking fails: [ilink32 Error] Fatal: Unable to open file 'DATA.OBJ' [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 3 days ago.
Improve this question
I'm trying to recompile a Windows C++ app inside a new compiler (RAD Studio 11). I'm an absolute beginner and running into a problem.
There is a .cbproj, DatabaseCppUtilities (32-bit), which threw an error. For it to compile and link successfully, I included dbrtl.lib so it could find Data::DB::TDataSet::GetRecord.
Now I'm compiling a different .cbproj of the app, which is using DatabaseCppUtilities, and it gives me this error:
[ilink32 Error] Fatal: Unable to open file 'DATA.OBJ'
I have the feeling it's related to the dbrtl.lib.
As I already said, I'm an absolute beginner, and maybe I'm missing something really simple, but for now I can't see what to do next.
I tried searching for the .obj file in the intermediate output directories, but can't seem to find any file named Data.obj.
I tried adding the dbrtl.lib to the different .cbproj using #pragma link "dbrtl.lib" and putting its path in the Shared Options > Library path.

graphics.h - installed it, why still error? [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 6 years ago.
Improve this question
So i followed instructions from an another question answer in this page about how to install graphics.h And it resulted correctly. But when i included it, it showed me this error message:
C:\Program Files\CodeBlocks\MinGW\include\graphics.h|302|error: redefinition of 'int right'|
C:\Program Files\CodeBlocks\MinGW\include\graphics.h|302|note: 'int right' previously declared here|
Why did this happend? Can you please help me fix this problem?
This is where i got the information from:
How to use graphics.h in codeblocks?
Did you followed the last resolution provided in the link you have specified?
Open the file graphics.h using either of Sublime Text Editor or Notepad++,from the include folder where you have installed Codeblocks.
Goto line no 302
Delete the line and paste int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX, in that line.
Save the file and start Coding.

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.

Can I port RetroArch to Native Client [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 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. :)

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"