Skip to main content
4 of 8
added 22 characters in body

1. Edit the Makefile

From

DESTDIR ?= /usr/local MANDIR ?= share/man/man3 

To

DESTDIR = /data/data/com.termux/files/usr/local MANDIR = /data/data/com.termux/files/usr/share/man/man3 

In the Makefile, the question mark equal sign (?=) is for asking if the variable isn't defined. In this case just force it to use the specified path.

2. Build & Install without SUDO

$ make install 

You'll end up getting an error at end

ldconfig /data/data/com.termux/files/usr/local/lib make: ldconfig: No such file or directory make: *** [Makefile:55: install] Error 127 

However the libraries are in the /data/data/com.termux/files/usr/local/lib directory and the man files should be in the right place

$ man get_string 

should display the CS50 man page for get_string

3. Add missing linking reference

More of a hack but works.

In build/lib there should be three files:

$ ls -1 libcs50.a libcs50.so libcs50.so.10.1.10 

These three same files should also be in: /data/data/com.termux/files/usr/local/lib

$ cd /data/data/com.termux/files/usr/local/lib $ ls -l .... libcs50.a .... libcs50.so -> libcs50.so.10.1.0 .... libcs50.so.10.1.0 

You'll need to add one symbolic link for libcs50.so.10:

$ ln -s libcs50.so.10.1.0 libcs50.so.10 $ ln -l .... libcs50.a .... libcs50.so -> libcs50.so.10.1.0 .... libcs50.so.10 -> libcs50.so.10.1.0 .... libcs50.so.10.1.0 

4. Add needed environment variables

$ export LIBRARY_PATH="/data/data/com.termux/files/usr/local/lib" $ export LD_LIBRARY_PATH="/data/data/com.termux/files/usr/local/lib" 

You'll probably want to add these to your shell environment.

5. Run test C code

$ cd <unzip_directory>/tests $ cc -lcs50 hackerrank.c $ ./a.out Message here: <type stuff> hello, <type stuff output> $ 

Always double check your environment variables with the export command if you are having problems compiling or running.

$ export ... ... declare -x LIBRARY_PATH="/data/data/com.termux/files/usr/local/lib" declare -x LD_LIBRARY_PATH="/data/data/com.termux/files/usr/local/lib" ... ...