0

I've tried to add the following lines to my makefile in order to add some MATLAB plots to my C++ routine, to set the environment variables:

export PATH='/APP/MATLAB/R2013a/bin':$PATH

export LD_LIBRARY_PATH='/APP/MATLAB/R2013a/bin/glnxa64:/APP/MATLAB/R2013a/sys/os/gnlxa64':$LD_LIBRARY_PATH

And to provide the code with the correct location for the include files at compilation time:

.cpp.o:
    g++ -c -DUNIX $(DEBUG) -I $(NR_DIR):/APP/MATLAB/R2013a/extern/include/ $<
$(CMD): $(OBJ)
    g++ -o $@ $(OBJ) -L$(NR_DIR) -lnr  -DUNIX -I $(NR_DIR):/APP/MATLAB/R2013a/extern/include/

Where I've only added :/APP/MATLAB/R2013a/extern/include/ to the includes.

The compilation runs normally, except that the one .cpp file I've made changes to (which is the one that requires the new includes) sends the following error:

enter image description here

which sounds like I should install g++ but how could that be if g++ is run for all the other files properly and it's also working just fine compiling the original program?

I would like to know if I am making a mistake in the compiler call and if the exports are not all right. This is working properly on my laptop but now that I've tried to migrate the program to our school's cluster it's become messy.

enter image description here

Alexis R Devitre
  • 288
  • 2
  • 6
  • 21

1 Answers1

2

The -I option to g++ does not presume a semicolon-divided directories list. This means you have to use -I option for each directory. Example:

-I $(NR_DIR) -I/APP/MATLAB/R2013a/extern/include
rayryeng
  • 102,964
  • 22
  • 184
  • 193
dmi
  • 1,424
  • 1
  • 9
  • 9
  • I've tried this modification but I still got the error... could there be anything wrong with the $<... I'm not familiar with this syntax and just trying to update somebody else (i don't know) work. – Alexis R Devitre Feb 23 '16 at 07:33
  • I don't really think so. Try to `echo` the `PATH` variable one line above prior running g++ in the Makefile, perhaps it is not correct. If not yet - please update the description with the recent version of the Makefile and the error. – dmi Feb 23 '16 at 07:44
  • wherever I put the "echo" it tells me "missing separator", would you mind telling me the right way to do this? – Alexis R Devitre Feb 23 '16 at 08:02
  • I can try, but I cannot do this blindly. Please update your issue description with the actual code according to my hints. – dmi Feb 23 '16 at 08:06
  • I've added the makefile as an image, the error is still the same – Alexis R Devitre Feb 23 '16 at 08:13
  • ah... you have `export PATH...` and LD_LIBRARY_PATH in your Makefile? Move them out, either to a shell script which starts the make command, or export by hands, but do not keep them in the Makefile! – dmi Feb 23 '16 at 08:16
  • Oh... what's wrong with that? I used to run it like that on my local computer and it worked... Also, how often should these be run? On my computer I needed to do so every time I wanted to execute the code which is why I ended up putting them in the Makefile – Alexis R Devitre Feb 23 '16 at 08:19
  • I cannot say for sure whether this is correct or not, but at least I have never seen exporting from Makefiles. You can leave it if you like, but if you need to find the root cause of your issue I would recommend to remove those two lines from Makefile. – dmi Feb 23 '16 at 08:23
  • Ok, I did and I still get the same result... I am now running a script which does the exports then runs make as you advised. – Alexis R Devitre Feb 23 '16 at 08:26
  • I just noticed, in the Makefile you have added the second include after $< at the line 20. It should be before $< so, that $< ends the line. That would be the second finding. – dmi Feb 23 '16 at 08:30
  • That did it!! Now I have more mistakes to work on haha THANKS FOR SHARING YOUR TIME!! Also, would you mind explaining the syntax?? – Alexis R Devitre Feb 23 '16 at 08:37
  • You're welcome! Actually I don't have a very deep experience on the makefiles. I normally use cmake to generate them. So I am afraid to give you a wrong guidance. But I think there should be many howtos, like this for instance: https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html. Perhaps you can follow some of them just for the overall idea, and then dig into details basing on your code. – dmi Feb 23 '16 at 08:42
  • Thanks!! This is really helpful! – Alexis R Devitre Feb 23 '16 at 08:46