473,626 Members | 3,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compiling simple program with several files, UNIX

62 New Member
Hi everyone!
I am trying to compile a very simple program on UNIX, which consists of several files, each of them has a function that prints out a string of text.
Then the file with the main function call each of these functions.
Here are the codes in the files:

Expand|Select|Wrap|Line Numbers
  1. //****** hello.h
  2. void func_hello();
  3.  
  4.  
  5. //******hello.c
  6. #include <stdio.h>
  7. #include "hello.h"
  8. void func_hello()
  9. {
  10. printf("Hello, how are you?\n");
  11. }
  12.  
  13.  
  14. //****** myApp.c
  15. #include <stdio.h>
  16. #include "hello.h"
  17. void main()
  18. {
  19. func_hello();
  20. func_here();
  21. func_bye();
  22. }
  23.  
  24.  
And this is the output I get after trying to compile it using a makefile:

Expand|Select|Wrap|Line Numbers
  1. % make -f myMakefile
  2.  
  3. cc -o myApp hello.o here.o bye.o
  4. Undefined                       first referenced
  5.  symbol                             in file
  6. main                                /vol/PACK/SunWorkshop/SUNWspro/SC4.2/lib   /crt1.o
  7. ld: fatal: Symbol referencing errors. No output written to myApp
  8. *** Error code 1
  9. make: Fatal error: Command failed for target `myApp'
  10.  

Can anyone please tell me what's wrong here??? Please!
Feb 5 '08 #1
4 1603
mikelwagan
6 New Member
where is the makefile?
Feb 5 '08 #2
jewel87
62 New Member
here is my makefile:
Expand|Select|Wrap|Line Numbers
  1.  
  2. myApp : hello.o here.o bye.o
  3.         cc -o myApp hello.o here.o bye.o
  4.  
  5. hello.o : hello.c
  6.         cc -c hello.c
  7. here.o : here.c
  8.         cc -c here.c
  9. bye.o : bye.c
  10.         cc -c bye.c
  11.  
  12. clean :
  13.         rm -f hello.o here.o bye.o
  14.  
  15.  
  16.  
Feb 5 '08 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
So where is myApp.c compiled ??
Feb 5 '08 #4
jewel87
62 New Member
So where is myApp.c compiled ??
Actually, I was confused by your question at first, but then suddenly i got what you mean! Thank you a lot!!! It's now alright!
Feb 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
6168
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with itself. Everything you need is available at no costs (except download hassle and installation time). Once your system is set up properly its just a matter of running 'python setup.py build'. No longer waiting for someone else to build binaries and a...
4
2734
by: Jimmie | last post by:
Sorry to bother you guys but I am kind of new to compiling c++ source code on unix systems. My problem is, I have a basic class program that calculates the stattistical values of 30 integers, I compiled it on borland it the program worked great, but when i tried to compile it on my schools unix system i recieve this error. /usr/libexec/elf/ld: final link failed: Disc quota exceeded if any one has any idea on what to do please email...
6
1468
by: johnnieboy | last post by:
I am trying to compile the program hull http://cm.bell-labs.com/netlib/voronoi/hull.html This is quite a complicated program that involves several .c files I get several warnings during compilation and the error: hullmain.c:40: initializer element is not constant This is the offending line: FILE *INFILE, *OUTFILE, *DFILE = stderr, *TFILE;
6
2087
by: wooks | last post by:
Sorry if this is very basic. I have bought a Functional Programming book that uses the language Hope. I have managed to locate and extract Ross Pattersons hope interpreter from http://www.soi.city.ac.uk/~ros s/Hope/ However it seems what I have got is the C source code and I haven't got a clue what to do with it.
0
9737
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
9
2190
by: Sheldon | last post by:
Good day Everyone, I am a still very new at learning C and I have thrown myself in the deep end. I started with a simple program and kept widening the scope. This has taught me many things about C and some, I must admit, have not really sunk in yet. Still, I push on. Now I am taken a library of C programs that were designed to read HDF files. I work on a Unix server and in Mandrake10. The program below is most likely broken but I cannot...
10
2202
by: Tomás Ó hÉilidhe | last post by:
I'd post this on a gcc newsgroup but I'd be more productive talking to the wall. Anyway, let's say someone throws some source code at you for a particular program and says, "Just compile it, it works fine". Now admittedly, I tend to have a phobia of this situation because I recall from my Windows days the numerous times I was given code that was supposedly "good to go", but which failed to compile for some stupid reason. Of course I...
60
4074
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On May 3, 8:09 am, apati...@gmail.com wrote: A programmer that uses Vista? :O Vista is a hog of an operating system. Downgrade to Windows XP or get yourself a Linux distro.
6
3517
by: Oliver Graeser | last post by:
Ok, stupid question.... I used to write programs all into one text files and compile them. Works, fine. Then I discovered XCode (or IDEs in general) which appear to be really increasing my productivity, so I use XCode with the settings for a command line C++ tool. Works fine, too. Then I split up my source code into many files. After figuring out the #ifndef stuff, that works great, even better.
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.