vrsperanza/CPY

ArchLinux: Unable to compile code

Closed this issue ยท 7 comments

Hi,

When entering the Simple sum directory and entering cpy main.cpy, I get the following output:

g++ -c main.cpp -o main.o
g++ -o ../a main.o

But ../a is nowhere to be found:

ls ../a
ls: cannot access '../a': No such file or directory.

Trying to run the sample code with -r did not give any results here either:

cpy -r main.cpy
g++ -o ../a main.o
Running code:
sh: ../a: No such file or directory

How are the samples meant to be run? I could not find any documentation for this.

I'm on 64-bit Arch Linux using GCC 8.1.0.

It compiles code inside the "compilationSource" folder, the line "g++ -o ../a main.o" links the object files and moves the executable to your project's root folder.
In this case, after running "cpy main.cpy", the command "./a" should sucessfully run the code.

I could not reproduce this problem with -r, will try again in another linux build today (probably)

No a executable is generated in the parent directory here:

/tmp/test% ls -al
total 4
drwxr-x---  2 alexander alexander  60 May 28 09:22 .
drwxrwxrwt 16 root      root      440 May 28 09:22 ..
-rw-r-----  1 alexander alexander 650 May 28 09:22 main.cpy
/tmp/test% cpy main.cpy 
g++ -c main.cpp -o main.o
g++ -o ../a main.o 
/tmp/test% ls -al ../a
ls: cannot access '../a': No such file or directory
/tmp/test% ls -al a
ls: cannot access 'a': No such file or directory
/tmp/test% 

c++ works fine:

/tmp/test% cat main.cpp 
#include <iostream>

int main() {
        std::cout << "hi" << std::endl;
        return 0;
}
/tmp/test% g++ main.cpp -o ../a
/tmp/test% ../a
hi
/tmp/test% 

I managed to reproduce the issue in archlinux and only in archlinux.
I honestly have no idea as to what's it's cause and will only be able to fully address it in a few days, in the meantime if you discover something, please let me know

I looked into this, and I believe that the line in main.cpp:

compilation += "-o " + trueTarget + " ";

should be

compilation += "-o " + target + " ";

because later on the following is done:

		remove(trueTarget.c_str());
		rename(target.c_str(), trueTarget.c_str());

Thank you okayzed
Issue should now be fixed