Find the answer to your Linux question:
Results 1 to 6 of 6
I wrote a simple Mortgage class, with simple attributes, (principle, rate, term) and methods that act on them. I instantiated an object of the class in the main() function, which ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    4

    Problems linking object files with geany on ubuntu

    I wrote a simple Mortgage class, with simple attributes, (principle, rate, term) and methods that act on them. I instantiated an object of the class in the main() function, which is defined in a separate file. Both source files compile and I have the .o files for each. When I try to build, I get a linker error:

    undefined reference to ClassName::MethodName

    How can I get Geany to tell the linker where these files are? I tried using the fully qualified path, but so far it just doesn't link them.

    Thanks

  2. #2
    Just Joined! pmcoleman's Avatar
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO USA
    Posts
    30
    I fought with geany for days before I figured out, after some google searching, that geany does not play well with multiple file c++ programs.

    Here is what I found that worked for me from the command line, after using geany to code the project.

    Compile the function cpp and header files first.
    -c is the compile option followed by the name of the source file.
    -o is the output option and the name of the file you want to use with the .o extension.
    # g++ -c <member function source> -o <member function source.o>

    Do much the same for the main driver file. Geany likes to see the driver named main.o
    # g++ -c <driver file> -o main(or other file name)

    Build the whole project:
    List all of the project files that you want linked and built. Choose a name for the output file, again geany likes to see main without the .o extension.
    # g++ <file.o> <member function.o> -o main or other name (geany likes to see "main")

    While this method is not a real time saver. I used it for some time before fixing my eclipse installation with the c++ plugins. There was just not enough time to deal with eclipse even though geany was not working well out of the box either. After finishing my project, I upgraded the OS and dealt with eclipse. I have since switched to using Sun Microsystems' Sun Studio... MUCH better IDE

    Good luck

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    4
    Thanks pmcoleman,

    I'll give that a go this evening when I get home. I also thought about eclipse, but was hoping to get something simpler and as you said, working out of the box. Ajunta didn't work too well, and I liked Geany's interface. But if I'm going to be using command line options, I might just prefer Vim. I'll have a look at Sun Studio too.

    Thanks again.

  4. #4
    Just Joined! pmcoleman's Avatar
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO USA
    Posts
    30
    Indeed. The interface was geanys plus on my decision as well. And it was easy on the resources compared with eclipse and Sun Studio. I still use geany from time to time when I just need a quick one or two file hack and when I am coding on a remote server, vim.

    Good coding....

  5. #5
    Just Joined!
    Join Date
    Mar 2009
    Posts
    4
    Yeah, -- in addition, I'm running Ubuntu on a Dell mini-9 laptop, so in addition to the interface, the fact that it's fairly lightweight was a plus. I don't think this box has the resources to run Sun Studio or eclipse. Anyways,

    Good coding to you too.

  6. #6
    Just Joined!
    Join Date
    Mar 2009
    Posts
    4
    Just thought I'd let you know, the command line instructions worked perfectly. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...