LinuxQuestions.org
Review your favorite Linux distribution.
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 05-31-2004, 10:51 PM   #1
sheenak
LQ Newbie
 
Registered: Apr 2004
Posts: 23

Rep: Reputation: 15
Red face creating a project with directory strucure.


Hi,

I am using kdeveloper to create a C++ project.
I have created a directory structure in it.
for eg,
test_dir :main folder
Include, Src : sub folders in test_dir
prj1, prj2: sub folders in Include ( to include .h header files)
prj1, prj2: sub folders in Src ( to include .cpp source files)
let b1.h, b2.h, b1.cpp, b2.cpp are the header and source files included in prj1, prj2, prj1, prj2 resp.

let b1.h be
----------------

#ifndef STRREV
#define STRREV
#include<iostream.h>

void strrev(char * source);

#endif

let b2.h be
-----------------

#ifndef STRLEN
#define STRLEN
#include< iostream.h>

int strlen1(char *);

#endif

let b1.cpp be
------------------
#include "/home/sheena/test_dir/test_dir/Include/prj2/b2.h" //path for include file
#include "/home/sheena/test_dir/test_dir/Include/prj1/b1.h"

void strrev(char * source)
{
int i,j;
char dest;
int n=strlen1(source);
for(i=0,j=n-1;i<j;i++,j--)
{
dest = source[i];
source[i]=source[j];
source[j]= dest;
}
source[n]='\0';
cout<<source;
}

int strlen1(char *source)
{
int n=0;
while(source[n] != '\0')
n++;
return n;
}


let b2.cpp be
------------------
#include "/home/sheena/test_dir/test_dir/abc1/a2/b2.h"
#include "/home/sheena/test_dir/test_dir/abc1/a1/b1.h"

int main()
{
int n;
char * source ="sheena";
strrev(source);
n= strlen1(source);
cout<<"\n length is "<<n<<endl;
return 0;
}

------------------------------------------------------------------------------------

All my files b1.cpp and b2.cpp are compiling successfully, but during executing this small program i am getting some linking error like follow:

gmake: Entering directory `/home/sheena/test_dir'
gmake all-recursive
gmake[1]: Entering directory `/home/sheena/test_dir'
Making all in test_dir
gmake[2]: Entering directory `/home/sheena/test_dir/test_dir'
Making all in abc1
gmake[3]: Entering directory `/home/sheena/test_dir/test_dir/abc1'
Making all in a1
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc1/a1'
gmake[4]: Nothing to be done for `all'.
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc1/a1'
Making all in a2
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc1/a2'
gmake[4]: Nothing to be done for `all'.
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc1/a2'
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc1'
gmake[4]: Nothing to be done for `all-am'.
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc1'
gmake[3]: Leaving directory `/home/sheena/test_dir/test_dir/abc1'
Making all in abc2
gmake[3]: Entering directory `/home/sheena/test_dir/test_dir/abc2'
Making all in a1
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc2/a1'
source='b1.cpp' object='b1.o' libtool=no \
depfile='.deps/b1.Po' tmpdepfile='.deps/b1.TPo' \
depmode=gcc3 /bin/sh ../../../admin/depcomp \
g++ -DHAVE_CONFIG_H -I. -I. -I../../.. -Wnon-virtual-dtor -Wno-long-long -Wbad-function-cast -Wundef -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2 -O0 -g3 -Wall -fno-exceptions -fno-check-new -c -o b1.o `test -f b1.cpp || echo './'`b1.cpp
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
from /home/sheena/test_dir/test_dir/abc1/a2/b2.h:19,
from b1.cpp:18:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
b1.cpp:44:2: warning: no newline at end of file
rm -f liba1.a
ar cru liba1.a b1.o
ranlib liba1.a
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc2/a1'
Making all in a2
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc2/a2'
source='b2.cpp' object='b2.o' libtool=no \
depfile='.deps/b2.Po' tmpdepfile='.deps/b2.TPo' \
depmode=gcc3 /bin/sh ../../../admin/depcomp \
g++ -DHAVE_CONFIG_H -I. -I. -I../../.. -Wnon-virtual-dtor -Wno-long-long -Wbad-function-cast -Wundef -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2 -O0 -g3 -Wall -fno-exceptions -fno-check-new -c -o b2.o `test -f b2.cpp || echo './'`b2.cpp
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
from /home/sheena/test_dir/test_dir/abc1/a2/b2.h:19,
from b2.cpp:17:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
b2.cpp: In function `int main()':
b2.cpp:24: warning: deprecated conversion from string constant to `char*'
rm -f liba2.a
ar cru liba2.a b2.o
ranlib liba2.a
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc2/a2'
gmake[4]: Entering directory `/home/sheena/test_dir/test_dir/abc2'
gmake[4]: Nothing to be done for `all-am'.
gmake[4]: Leaving directory `/home/sheena/test_dir/test_dir/abc2'
gmake[3]: Leaving directory `/home/sheena/test_dir/test_dir/abc2'
gmake[3]: Entering directory `/home/sheena/test_dir/test_dir'
/bin/sh ../libtool --silent --mode=link gcc -ansi -W -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -O2 -o test_dir ./abc2/a1/liba1.a ./abc2/a2/liba2.a
./abc2/a2/liba2.a(b2.o): In function `main':
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:25: undefined reference to `strrev(char*)'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:26: undefined reference to `strlen1(char*)'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:27: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:27: undefined reference to `std::cout'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:27: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:27: undefined reference to `std::basic_ostream<char, std::char_traits<char> >:perator<<(int)'
/home/sheena/test_dir/test_dir/abc2/a2/b2.cpp:27: undefined reference to `std::basic_ostream<char, std::char_traits<char> >:perator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
./abc2/a2/liba2.a(b2.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/3.2/iostream:62: undefined reference to `std::ios_base::Init::Init[in-charge]()'
./abc2/a2/liba2.a(b2.o): In function `__tcf_0':
/usr/include/c++/3.2/iostream:62: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
collect2: ld returned 1 exit status
gmake[3]: *** [test_dir] Error 1
gmake[3]: Leaving directory `/home/sheena/test_dir/test_dir'
gmake[2]: Leaving directory `/home/sheena/test_dir/test_dir'
gmake[1]: Leaving directory `/home/sheena/test_dir'
gmake: Leaving directory `/home/sheena/test_dir'
gmake[2]: *** [all-recursive] Error 1
gmake[1]: *** [all-recursive] Error 1
gmake: *** [all] Error 2
*** failed ***

---------------------------------------------------------------------------

if any one know the solution please help me out.

Regards,
Sheena
 
Old 06-03-2004, 04:18 AM   #2
amit201
LQ Newbie
 
Registered: Jun 2004
Location: India
Posts: 1

Rep: Reputation: 0
One solution to this problem is..

keep the file which contain main function in the directory where you have created the project. This is just a workaround. I am working on the root cause of the problem. will let you know as got the final solution.

Regards,
Amit
 
Old 06-03-2004, 07:16 AM   #3
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Hi Amit,

Thank you very much.
Its working now.
I just want to know the reason for the same.

Regards,
Sheena
 
  


Reply



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
Advice on creating new directory satimis Linux From Scratch 4 06-27-2005 08:34 PM
Creating new subdirectory for a C++ project Siavash Programming 2 04-10-2005 03:09 PM
Creating Pop-ups in Visual C++ (MFC Project) zWaR Programming 1 08-18-2004 02:22 PM
Creating a login for a directory Renaxgade Linux - Software 2 10-18-2003 12:16 AM
Problem creating KDE project with KDevelop 2.0.1 stodge Programming 4 01-24-2002 06:22 AM

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

All times are GMT -5. The time now is 05:54 PM.

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