Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling with gcc in blueCFD-Core terminal #40

Closed
obscureed opened this issue Feb 3, 2017 · 4 comments
Closed

Compiling with gcc in blueCFD-Core terminal #40

obscureed opened this issue Feb 3, 2017 · 4 comments

Comments

@obscureed
Copy link

I have installed blueCFD-Core (latest release, SHA-1 4ba23f6757ccdfd041f2e2627daee7b947f41195) on Windows 7, in C:\Program Files\blueCFD-Core-2016. Many features work seamlessly --thanks!

However, when I try to compile a standalone C program from the blueCFD-Core terminal, using a command like "gcc code.c -o code.exe", I get the following error:

C:\Program Files\blueCFD-Core-2016\msys64\mingw64\bin/ld.exe: cannot find C:/Program: No such file or directory
C:\Program Files\blueCFD-Core-2016\msys64\mingw64\bin/ld.exe: cannot find Files/blueCFD-Core-2016/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
collect2.exe: error: ld returned 1 exit status

It seems that the path for ld.exe is not understood inside the Linux-like file system. (If I type "which ld" or "which ld.exe" or "which gcc", the programs are listed as being in /mingw64/bin, which is in the $PATH of the blueCFD-Core terminal. A command "ld --version" is successful. In a standard Windows cmd window, "ld" and "ld.exe" are not recognised, so there is no conflicting path to a different ld.exe.)

I expect that this is a bug in msys2, not the fault of blueCFD-core. (It may be related to blueCFD-core issue #2.) Please can you comment?

@wyldckat
Copy link
Member

wyldckat commented Feb 3, 2017

Many thanks for your positive feedback!

Sorry about the problem with the space in "Program Files". The workaround for this is written here: https://github.com/blueCFD/Core/wiki/Quick-notes-on-how-to-update-build#setting-up-the-work-environment - namely in section "Setting up the work environment".

A partial fix for this issue is already available in our git repository, which can be gotten if you follow the instructions given on that page.

The missing part of the fix is that you've used the gcc command directly, for which we don't have a fix yet, at least as far as I can remember. The workaround still solves that problem, but the workaround we have in the latest git commit is relying on the script makeReinterpretExePath, which can be used as follows:

$($WM_DIR/scripts/makeReinterpretExePath gcc) code.c -o code.exe

Keep in mind that this will only work if you follow the instructions given at the aforementioned wiki page.

You can also add an alias to your ~/.bashrc file that does this for you, when doing it manually:

alias gcc=$($WM_DIR/scripts/makeReinterpretExePath gcc)
alias g++=$($WM_DIR/scripts/makeReinterpretExePath g++)

The start a new terminal window or source said file to load in the aliases. Then you can use the command manually once again:

gcc code.c -o code.exe

Note: This will not work inside a shell script, because aliases are disabled by default within scripts.

@wyldckat wyldckat self-assigned this Feb 3, 2017
@wyldckat wyldckat added this to the blueCFD-Core-2016-2 milestone Feb 3, 2017
@obscureed
Copy link
Author

Thanks for the super-fast response.
I have followed the instructions for mapping the drive letter. (The instructions do not fit my installation 100% -- I do not have an Extended Start Menu, but the Settings folder is right there anyway.)

I do not have makeReinterpretExePath in $WM_DIR/scripts. I do have makeReinterpretObjectPaths. Using that, I get an error:

$ ($WM_DIR/scripts/makeReinterpretObjectPaths gcc) gb_flip.c sat13.c -o sat13.exe
bash: syntax error near unexpected token `gb_flip.c'

But actually, with the terminal window launched from the X: drive, plain "gcc" works fine now. So that's a workaround, as you said. Thanks! (Should I close the issue?)

@wyldckat
Copy link
Member

wyldckat commented Feb 3, 2017

You're welcome for the fast response :)

makeReinterpretExePath is only available if you get the latest developments, as explained here: https://github.com/blueCFD/Core/wiki/Quick-notes-on-how-to-update-build#updating-the-build-of-openfoam-4x-in-bluecfd-core-2016 - section "Updating the build of OpenFOAM 4.x in blueCFD-Core 2016"

I prefer to leave this report open for now, because I also want to also fix the issue with using gcc or g++ from the command line. Hopefully I'll have this fixed in a few weeks.

wyldckat added a commit that referenced this issue Sep 1, 2017
@wyldckat
Copy link
Member

wyldckat commented Sep 1, 2017

Added a ton of details about this on the FAQ entry: http://bluecfd.github.io/Core/FAQ/having-other-problems-with-custom-source-code/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants