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

CMAKE compile breaks when an existing SWI is installed #435

Closed
ssardina opened this issue Feb 26, 2019 · 5 comments
Closed

CMAKE compile breaks when an existing SWI is installed #435

ssardina opened this issue Feb 26, 2019 · 5 comments

Comments

@ssardina
Copy link
Contributor

Have done the standard for a minimal install that includes JPL:

git clone https://github.com/SWI-Prolog/swipl-devel.git
cd swipl-devel/
git submodule update --init packages/jpl packages/clib packages/sgml
mkdir build
cd build/
cmake .. -DINSTALL_DOCUMENTATION=OFF
make

And after a while:

[ 82%] Built target prolog_home
Scanning dependencies of target prolog_products
[ 83%] Generating ../home/boot.prc
[ 83%] Generating ../home/library/INDEX.pl
[FATAL ERROR: at Wed Feb 27 07:54:06 2019
	Could not find system resources]
src/CMakeFiles/prolog_products.dir/build.make:91: recipe for target 'home/library/INDEX.pl' failed
make[2]: *** [home/library/INDEX.pl] Error 2
CMakeFiles/Makefile2:828: recipe for target 'src/CMakeFiles/prolog_products.dir/all' failed
make[1]: *** [src/CMakeFiles/prolog_products.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I will check now including all modules, but I am assuming it should still work with chosen modules.

@ssardina
Copy link
Contributor Author

ssardina commented Feb 26, 2019

Bingo! I found the problem.

I already have SWI installed, as part of the distro, and SWI_HOME pointing to /usr/lib/swi-prolog/ which then interferes with the compilation when cmake calls swipl producing the Could not find system resources error.

While this can be fixed manually, by unsetting SWI_HOME var, it would be best if CMAKE does that automatically for the compilation. How can we improve this?

@JanWielemaker
Copy link
Member

SWI_HOME doesn't seem defined. I see SWI_HOME_DIR and SWIPL. Or, am I missing something?
There is cmake/CheckEnv.cmake that should cause a big warning if there is a conflicting variable in the environment. Extend as needed. I don't think ninja has anything to unset variables. Possibly we could set them ourselves, either to something harmless or to the place we are building anyway. That will fix the build, but still install a system that doesn't work.

@ssardina
Copy link
Contributor Author

Sorry, you are not missing anything, I am missing the _DIR, it is indeed SWI_HOME_DIR.

I will look at cmake/CheckEnv.cmake and how to set that env var.

You are right, this will allow the compile to work, because part of the compilation involves running the newly compiled executable.

You are right about the install, that won't fix it. If you still have the SWI_HOME_DIR var pointing to a previous SWI version, then that previous version will be used. But so be it, if you install the new compiled version somewhere, you need to adapt your variables if you want to use it. I am adding that info in the CMAKE.md doc.

What I found interesting is that if I change SWI_HOME_DIR to point to the new path, say /usr/local/swipl-git/lib/swipl/, then that is enough to run the new compiled SWI even if the old SWI is the one in the PATH. I also needs the correct LD_LIBRARY_PATH set to find libswipl.so.

So, I am assuming that even the distribution installed version /usr/bin/swipl will run the manually installed SWI if SWI_HOME_DIR and LD_LIBRARY_PATH point to it (the manually installed version).

This is what I mean:

[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ echo $SWI_HOME_DIR 
/usr/lib/swi-prolog/
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- ^D
% halt
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ which swipl
/usr/bin/swipl
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ 
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ export SWI_HOME_DIR=/usr/local/swipl-git/lib/swipl/
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ which swipl
/usr/bin/swipl
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ swipl
[FATAL ERROR: at Wed Feb 27 10:55:35 2019
	Could not find system resources]
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ export LD_LIBRARY_PATH=/usr/local/swipl-git/
bin/   lib/   share/ 
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ export LD_LIBRARY_PATH=/usr/local/swipl-git/lib/swipl/
bin/        boot.prc    doc/        lib/        LICENSE     swipl.home  
boot/       demo/       include/    library/    README.md   
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ export LD_LIBRARY_PATH=/usr/local/swipl-git/lib/swipl/lib/x86_64-linux/
[ssardina@Thinkpad-X1 sarl-prolog-cap.git]$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.1-41-ge94e85740)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- 
|    ^D
% halt

So, I think if we fix the issue to be able to compile and then make all this clear in the doc, it is all good.

@ssardina ssardina changed the title CMAKE compile breaks CMAKE compile breaks when an existing SWI is installed Feb 27, 2019
@ssardina
Copy link
Contributor Author

This has been resolved and is included in PR #433

Basically we need to check that either swipl or swi-prolog strings are in the env variables.

Also handled the check of whether a var is defined a bit cleaner and fixed a couple of typos when checking for conflicting env variables.

Finally, documentation CMAKE.md has been improved.

@ssardina
Copy link
Contributor Author

Fixed as part of PR #433

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

No branches or pull requests

2 participants