473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compile two .cpp files together...

So here I am,working on some code which requires me to compile two files and one object code files together.
Here is the skeleton of my code in file.cpp

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. class someclass{
  3. public:
  4. somevariable *sm;
  5. };
  6.  
  7. someclass *sm[4];
  8.  
  9. void somemethod();
  10.  
  11. int someanothermethod(somevariable *me);
  12.  
  13. int main()
  14. {
  15.  
  16. somemethod();
  17. some code which calls someanothermethod()..
  18.  
  19.  
  20. return 0;
  21. }
  22.  
And the other file2.cpp file would contain my someanothermethod() definition and its code.Here somemethod() is called from another object file smthing.o.... So in a nutshell I have to do ...
g++ file1.cpp smthing.o file2.cpp

After I do that...it gives me error that

error:‘someanothermethod’ was not declared in this scope
error: ‘me’ was not declared in this scope


Whats going wrong here? Further I dont want to deal with new header files.
Any help would be appreciated.

Thanks in advance.
Feb 13 '11 #1
3 2460
horace1
1,510 Expert 1GB
for a start you have missed the ; after the } on line 5 which terminates the class definition
Feb 13 '11 #2
Ohh...that was a serious typo...I have updated it...
Its just that I ve run that command and somehow compiler is not linking them together.
Thanks for pointing out mistake.
Feb 13 '11 #3
horace1
1,510 Expert 1GB
what error do you get now?
I assume you have compiled somthing.c
Expand|Select|Wrap|Line Numbers
  1. g++  somthing.c 
  2.  
check you spelling, your command
Expand|Select|Wrap|Line Numbers
  1.  g++ file1.cpp smthing.o file2.cpp 
is smthing.o correct?
Feb 14 '11 #4

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

Similar topics

3
by: JHenstay | last post by:
I've been doing quite alot of reading on C++ and classes, however, everything I read just talks about the code itself and not the location of the code. My question is, what if you want to...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
1
by: Christopher M. Lusardi | last post by:
Hello, I have a program that can be compiled and run on SGI and Linux computers, and only one of the files in the program has is different. On the SGI system, the file has a dot capital C...
4
by: aaj | last post by:
Hi all I have a group of files that I store independently in a temporary folder on the c: drive. Typical things are ini files, bitmaps, icons etc. All access to the files is hardcoded within my...
2
by: John Spiegel | last post by:
Hi all, I'm working with the .NET framework and Web Matrix and am having trouble finding how to tie together the files when deriving classes. What I've got is a TestBase.cs file that defines a...
4
by: Gary Wessle | last post by:
Hi is there a module to do things like concatenate all files in a given directory into a big file, where all the files have the same data formate? name address phone_no. or do I have to open...
7
by: shwetu | last post by:
If i place vb and cs class files together in App_Code in asp.net 2.0 i get error that i can't place as they us a different language which is not allowed as they have to be complied together. Is...
4
by: Tine Müller | last post by:
How can I mix this to one file showing all the markers on Sjælland var xmlfile = ; //Sjælland xmlfile = "map_data_xml.php?category=sh"; xmlfile = "map_data_xml.php?category=sf"; xmlfile =...
4
by: BerlinBrown | last post by:
Is it possible to just build the binary content of a zip file. I want to create the content in memory (e.g. return binary data) and then get those byte strings representing the zip file? Is that...
0
by: tvnaidu | last post by:
I have 3 source files called xyz1.c xyz2.c xyz3.c, also include directory parallel to these files, I need to compile them and create a static lib with this command, not working, any issue? gcc -g...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.