LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-30-2007, 12:07 AM   #1
myhanguk
LQ Newbie
 
Registered: Jun 2007
Posts: 5

Rep: Reputation: 0
Keep getting the message No such file or directory


Hi...
I'm new to linux and g++, and I'm writing here out of frustration when even simple things don't seem to work...

I'm trying to compile a small little test program that looks as follows:

#include <stdlib.h>
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int main(){
printf("%.22f\n", gsl_sf_bessel_J0(1.0));
return (0);
}

I have built and installed the GSL library in my home directory (instead of the default usr/local). libgsl.a is in myhomedir/lib and all header files are in myhomedir/include/gsl, including gsl_sf_bessel.h which I try to use.

I now try to compile program using a simple Makefile:
test: test.o
g++ test.cpp -I/user/myhomedir/include -L/user/myhomedir/lib libgsl.a -o test
when calling make, I keep getting the gsl/gsl_sf_bessel.h: No such file or directory ?????

What am I doing wrong?

Also, I wonder why make does not return any errors when I put a phony directory in, such as -I/phony/phony ?

Thanks for helping out!

Niko
 
Old 06-30-2007, 12:15 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Check for a mispelling, and check that the file actually exists. It should work whether you use angle brackets or double quotes.

I created an include directory in my home directory and moved a header file there. Adding the include directory argument for the command it worked as expected using first angle brackets and then double quotes.

Last edited by jschiwal; 06-30-2007 at 12:24 AM.
 
Old 06-30-2007, 12:30 AM   #3
myhanguk
LQ Newbie
 
Registered: Jun 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Hi jschiwal,
Quote:
#include "gsl/gsl_sf_bessel.h"
I tried that, but keep getting the message. Furthermore, the -I/user/myhomedir/include option should instruct the compiler/linker of the locations to search.

When I type at the command prompt:
g++ -I/user/myhomedir/include -v test.cpp

I get the following (partial output) which indicates that the -I option has been set:
...
#include <...> search starts here:
/user/myhomedir/include
/usr/include/c++/3.2.3
...

That's why I don't understand why I keep getting the message!

Niko
 
Old 06-30-2007, 12:41 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
My post mentioned that both ways should work, so cd to the gsl directory and make sure that that include file exists. Also check the permissions. Make sure the directory and the file are readable.
 
Old 06-30-2007, 12:46 AM   #5
myhanguk
LQ Newbie
 
Registered: Jun 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Hmm...

Hmm...jschiwal
You edited your first message, because it didn't first say that both should work... Is that good practice? Anyway...

Yes I checked that the file exists, is in the correct location, and is editable. These files are in my home directory.

Thanks

Niko
 
Old 06-30-2007, 01:19 AM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I'm wondering if maybe the problem is coming from "make" (and not, as we've been assuming, from the g++ compiler).

Suggestion:
Try compiling from the command prompt (you said you tried "-v", but you didn't say whether or not you actually tried a command-line compiler, or whether or not it worked).

Just a thought...
 
Old 06-30-2007, 03:54 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by myhanguk
Hmm...jschiwal
You edited your first message, because it didn't first say that both should work... Is that good practice? Anyway...

Yes I checked that the file exists, is in the correct location, and is editable. These files are in my home directory.

Thanks

Niko
Yes, I edited it just after posting it the first time. Sorry for the confusion.

Quote:
g++ test.cpp -I/user/myhomedir/include -L/user/myhomedir/lib libgsl.a -o test
If this command gives you that error, then the problem isn't due to make because make isn't used. The verbose command might give more information, but taking the error message at its word and checking the file it is complaining about seems like the best bet.
 
  


Reply

Tags
directory, g++, include



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc: installation problem, cannot exec `cc1': No such file or directory Error Message 08h Programming 2 07-20-2006 11:44 AM
gcc: installation problem, cannot exec `cc1': No such file or directory Error Message 08h Linux - Newbie 1 06-01-2004 04:26 AM
error message "no such file or directory" Luisa Linux - General 3 02-14-2004 02:40 PM
linux command error message bash: /usr/bin/find: No such file or directory sundaram123 Linux - General 8 04-02-2002 07:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration