Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

problem with compile

  • 26-01-2002 9:37am
    #1
    Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭


    I was trying to compile a program in linux, but I need a lot of librarys to do it so I'm using a file called ccgl to take the name of the source and compile the program with all the librarys specified in that file, so I only have to type out the list once. However when I go to compile I get the error below. I have ccgl in my /usr/bin directory, and I think that might be where one of the problems lie, ie only root has access to that directory, any ideas??
    /usr//bin/ccgl: prog1.c.c: command not found
    gcc: $: No such file or directory
    gcc: {NAME}: No such file or directory
    


Comments

  • Registered Users, Registered Users 2 Posts: 476 ✭✭Pablo


    which gcc


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    gah!!! to you

    I forget how to check, doh!!!, investigating...

    <EDIT>Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
    gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)

    wasnt so hard actually</EDIT>


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    em*bump*


  • Closed Accounts Posts: 296 ✭✭moist


    Well lets start with what ccgl is ?
    I'm assuming that it is a shell script of some sort?


    Anyhoo....
    Perhaps you should consider using make.
    Create a directory with the source of the program you want to compile in it,
    then create a file called "Makefile" in it with something like the following in it.
    Assuming the source is prog1.c and you want to compile it into a binary called prog1
    CC = gcc
    CFLAGS = -Wall ${INCLUDE} -pedantic -O3
    
    OBJECT = prog1.o
    BINARY = prog1
    ## Put the libs you want to link against on the next line
    LIBS = -lncurses -lreadline -lm 
    ## Paths to library directories on next line
    LIBDIRS = -L/usr/local/lib
    ## Paths to includes on next line
    INCLUDES = -I/usr/local/include
    
    all: ${BINARY}
    
    ${BINARY}: ${OBJECT}
            ${CC} ${CFLAGS} -o ${BINARY} ${OBJECT} ${LIBS} ${LIBDIRS} ${INCLUDES}
    
    prog1.o:              prog1.c 
    
    clean:
            rm -f *.o ${BINARY}
    
    

    Then you just type "make" to compile your program.
    "make clean" will clean up any old .o and binary files and leave
    you with a "clean" source directory.

    There are online manuals at gnu.org and I'm sure a quick google will find a good few more for you.


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    NAME=basename $1.c
    shift
    gcc -o ${NAME} -s -O3 $ {NAME} $* -L/usr/X11R6/lib -lglut -lx11 -lGl -lXi \
    -lGLu -lXMu -lm

    that is the contents of my ccgl file. Like I said its just to save me typing out all the different libraries i need to include, I hope you can help.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    I said in my first post that I thought it may be a permissions error, but I dont think that anymore as I have just checked the permissions on the folder in question and I do have execute permissions so I would not say its that.


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    digging around some more and I actually read the error message, why does it think that a source file is a command??

    I hope I'm giving somebody enough to go on, because I'm beyond stumped.

    Moist the reason I am doing it this way instead of a make file is because this method worked in college for me under unix, but unfortunately my lecturer set it up for me and I wasnt taking nearly enough notes. DOH!!


  • Closed Accounts Posts: 296 ✭✭moist


    First off, I forgot to ask, how are you calling ccgl ?
    Are you using it to compile one program (aka c file) at a time
    or multiple at once ?

    I'll assume that the script starts with #!/bin/sh (or similar) :)
    Originally posted by Baz_

    NAME=basename $1.c

    Are there actually quotes around that ?
    In fact I don't know why you are using basename.
    Lest say you want to compile ~/src/foo.c and your
    PWD is ~ if you use ccgl ~/src/foo $NAME will just be foo.c and gcc won't be able to find it.

    Just use NAME=$1.c.

    shift
    gcc -o ${NAME} -s -O3 $ {NAME} $* -L/usr/X11R6/lib -lglut -lx11 -lGl -lXi \
    -lGLu -lXMu -lm

    This looks like you are using ccgl to compile multiple source files into one program ?
    I'm not sure if its a typo but there is a space between the $ and the {NAME}.

    that is the contents of my ccgl file. Like I said its just to save me
    typing out all the different libraries i need to include, I hope you can help.


    Hmm... I'll give you 2 options...

    ONE You just want to compile one source file (prog.c) into a program (prog)
    used by calling " ccgl prog "
    #!/bin/sh
    
    ## Set the name of the output program
    NAME=$1
    ## Set the name of the source file
    SOURCE=${1}.c
    
    ## Compile it.
    gcc -o ${NAME} -s -O3 ${SOURCE} -L/usr/X11R6/lib \
    -lglut -lx11 -lGl -lXi -lGLu -lXMu -lm 
    
    


    TWO You want to compile multiple source files (source1.c source2.c ... sourceN.c)
    into a single program ( prog ).
    used by calling " ccgl prog source1.c source2.c ... sourceN.c "
    #!/bin/sh
    
    ## Set the name of the output program
    NAME=$1
    
    ## Shift the argument list so that $* only containes 
    ## the source files not the program name.
    shift
    
    ## Compile them into $NAME
    gcc -o ${NAME} -s -O3 $* -L/usr/X11R6/lib -lglut \
    -lx11 -lGl -lXi -lGLu -lXMu -lm 
    
    


    Now if neither of those do what you want them to, come back and tell us what you _expect_ ccgl to do.


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    okay thanks again moist, I havent tried either of them yet, but i will tell you what I expect it to do. I call it like you said "ccgl prog.c" thats the way I was calling it in college, although without the .c it also works. I had the ccgl file in my usr/bin directory, and had it set to executable. In college I was using Unix, I didnt use the shbang line there, I dont know if there would be any difference between linux and unix in this case, but I should think not, I'll try it anyway, because I really want this to work. So I invoke it with "ccgl prog" which compiles the source (obviously), and just basically creates an opengl executable. The reason all the libraries are there is so that all the necessary libraries are available for opengl programming.

    And yes that was a typo.

    I wont get a chance to try this until tomorrow so there is no point in replying until then, unless you want to clarify whether the shbang line should be there.

    Again thanks for your help


Advertisement