ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] compiling cpp and c files
@ 2004-10-21 13:04 Alexey Morsov
  2004-10-21 15:39 ` Yuri N. Glibovetz
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Alexey Morsov @ 2004-10-21 13:04 UTC (permalink / raw)
  To: ALT Linux Community

Привет,

Хочу скомпилировать вместе main.cpp и common.c - и не получается. 
Т.е. make компилит отдельно и то и другое но вместе их сливать ен 
зочет, ругается что в файле main.cpp undefined function **** - 
которая как раз в common.c .

Как это можно соить (ведь можно же как-то)?

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
ICQ: 196766290
Jabber: Samurai@jabber.pibhe.com
http://www.ricom.ru
http://www.fondmarket.ru


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-21 13:04 [Comm] compiling cpp and c files Alexey Morsov
@ 2004-10-21 15:39 ` Yuri N. Glibovetz
  2004-10-22  6:33   ` Alexey Morsov
  2004-10-21 15:42 ` Denis Kirienko
  2004-10-21 19:28 ` scor
  2 siblings, 1 reply; 10+ messages in thread
From: Yuri N. Glibovetz @ 2004-10-21 15:39 UTC (permalink / raw)
  To: community

Alexey Morsov пишет:

> Привет,
> 
> Хочу скомпилировать вместе main.cpp и common.c - и не получается. Т.е. 
> make компилит отдельно и то и другое но вместе их сливать ен зочет, 
> ругается что в файле main.cpp undefined function **** - которая как раз 
> в common.c .
> 
> Как это можно соить (ведь можно же как-то)?
> 

extern "C" ... ;)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-21 13:04 [Comm] compiling cpp and c files Alexey Morsov
  2004-10-21 15:39 ` Yuri N. Glibovetz
@ 2004-10-21 15:42 ` Denis Kirienko
  2004-10-22  6:32   ` Alexey Morsov
  2004-10-21 19:28 ` scor
  2 siblings, 1 reply; 10+ messages in thread
From: Denis Kirienko @ 2004-10-21 15:42 UTC (permalink / raw)
  To: community

Получил Thu, 21 Oct 2004 17:04:10 +0400 от Alexey Morsov
<samurai@ricom.ru> следующее письмо:

> Хочу скомпилировать вместе main.cpp и common.c - и не получается. 
> Т.е. make компилит отдельно и то и другое но вместе их сливать ен 
> зочет, ругается что в файле main.cpp undefined function **** - 
> которая как раз в common.c .
> 
> Как это можно соить (ведь можно же как-то)?

Вы бы хотя бы сообщение об ошибке привели полностью...

Насколько я понял, у Вас функция не определена в main.cpp, откуда вы
ее вызываете. Добавьте в файл main.cpp строку с описанием этой функции
вида

int myfunc(int, double, char*);

соответствующую определению этой функции.

Еще более кошерный способ - сделать файл common.h следующего
содержания:

#ifndef _COMMON_H_
#define _COMMON_H_
int myfunc(int, double, char*);
#endif

и включить его в файлы common.cpp и main.cpp:

#include "common.h"


--
Денис
 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-21 13:04 [Comm] compiling cpp and c files Alexey Morsov
  2004-10-21 15:39 ` Yuri N. Glibovetz
  2004-10-21 15:42 ` Denis Kirienko
@ 2004-10-21 19:28 ` scor
  2 siblings, 0 replies; 10+ messages in thread
From: scor @ 2004-10-21 19:28 UTC (permalink / raw)
  To: community

On Thu, Oct 21, 2004 at 05:04:10PM +0400, Alexey Morsov wrote:
> Привет,
> 
> Хочу скомпилировать вместе main.cpp и common.c - и не получается. 
> Т.е. make компилит отдельно и то и другое но вместе их сливать ен 
> зочет, ругается что в файле main.cpp undefined function **** - 
> которая как раз в common.c .
> 
> Как это можно соить (ведь можно же как-то)?

--makefile--

xmain: board.o
	g++ main.cpp -o xmain board.o -g -lgrx20X -lX11 -L/usr/X11R6/lib

board.o:
	g++ board.cpp -g -o board.o -lgrx20X -lX11  -L/usr/X11R6/lib

clear:
	rm -f xmain *.o

--end--

-- 
С уважением: scor_at_mf.volsu.ru
------- ICQ UIN 346283813 -------
------ JID scor2k@jabber.ru -----

Здесь вам не тут - здесь вас быстро отвыкнут водку пьянствовать 
и безобразия нарушать.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-21 15:42 ` Denis Kirienko
@ 2004-10-22  6:32   ` Alexey Morsov
  2004-10-22  9:02     ` Yuri N. Glibovetz
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Morsov @ 2004-10-22  6:32 UTC (permalink / raw)
  To: community

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]


Denis Kirienko wrote:
> Вы бы хотя бы сообщение об ошибке привели полностью...
> 
> Насколько я понял, у Вас функция не определена в main.cpp, откуда вы
> ее вызываете. Добавьте в файл main.cpp строку с описанием этой функции
> вида
Да вроде все определено, пока файл назывался .c а не .cpp все 
компилировалось замечательно...

Прилагаю архив с программой и доп.файлами - думаю проще 
посмотреть чем я буду косноязычно объяснять :)

Заранее спасибо.

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
ICQ: 196766290
Jabber: Samurai@jabber.pibhe.com
http://www.ricom.ru
http://www.fondmarket.ru

[-- Attachment #2: soft.tar.gz --]
[-- Type: application/x-gzip, Size: 20843 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-21 15:39 ` Yuri N. Glibovetz
@ 2004-10-22  6:33   ` Alexey Morsov
  0 siblings, 0 replies; 10+ messages in thread
From: Alexey Morsov @ 2004-10-22  6:33 UTC (permalink / raw)
  To: community


Yuri N. Glibovetz wrote:

> Alexey Morsov пишет:
> 
>> Привет,
>>
>> Хочу скомпилировать вместе main.cpp и common.c - и не получается. Т.е. 
>> make компилит отдельно и то и другое но вместе их сливать ен зочет, 
>> ругается что в файле main.cpp undefined function **** - которая как 
>> раз в common.c .
>>
>> Как это можно соить (ведь можно же как-то)?
>>
> 
> extern "C" ... ;)
Добавил по типу как в mysql.h

#ifdef __cplusplus
extern "C" {
#endif

и потом после всех объявлений функций
#ifdef __cplusplus
}
#endif

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
ICQ: 196766290
Jabber: Samurai@jabber.pibhe.com
http://www.ricom.ru
http://www.fondmarket.ru


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-22  6:32   ` Alexey Morsov
@ 2004-10-22  9:02     ` Yuri N. Glibovetz
  2004-10-22  9:23       ` Alexey Morsov
  0 siblings, 1 reply; 10+ messages in thread
From: Yuri N. Glibovetz @ 2004-10-22  9:02 UTC (permalink / raw)
  To: community

Alexey Morsov пишет:
> 
> Denis Kirienko wrote:
> 
>> Вы бы хотя бы сообщение об ошибке привели полностью...
>>
>> Насколько я понял, у Вас функция не определена в main.cpp, откуда вы
>> ее вызываете. Добавьте в файл main.cpp строку с описанием этой функции
>> вида
> 
> Да вроде все определено, пока файл назывался .c а не .cpp все 
> компилировалось замечательно...
> 
> Прилагаю архив с программой и доп.файлами - думаю проще посмотреть чем я 
> буду косноязычно объяснять :)
> 
> Заранее спасибо.

Добавте в LIBS -lstdc++


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-22  9:02     ` Yuri N. Glibovetz
@ 2004-10-22  9:23       ` Alexey Morsov
  2004-10-22  9:36         ` Yuri N. Glibovetz
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Morsov @ 2004-10-22  9:23 UTC (permalink / raw)
  To: community


Yuri N. Glibovetz wrote:

>> Прилагаю архив с программой и доп.файлами - думаю проще посмотреть чем 
>> я буду косноязычно объяснять :)
>>
>> Заранее спасибо.
> 
> 
> Добавте в LIBS -lstdc++
О! Пасибо! Сработало! А почему так? Была у нас прогга на cpp 
которая использовала mysqllib - который вроде ж на c и без этой 
опции обходились прекрасно?

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
ICQ: 196766290
Jabber: Samurai@jabber.pibhe.com
http://www.ricom.ru
http://www.fondmarket.ru


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-22  9:23       ` Alexey Morsov
@ 2004-10-22  9:36         ` Yuri N. Glibovetz
  2004-10-22  9:53           ` Alexey Morsov
  0 siblings, 1 reply; 10+ messages in thread
From: Yuri N. Glibovetz @ 2004-10-22  9:36 UTC (permalink / raw)
  To: community

Alexey Morsov пишет:

> 
> Yuri N. Glibovetz wrote:
> 
>>> Прилагаю архив с программой и доп.файлами - думаю проще посмотреть 
>>> чем я буду косноязычно объяснять :)
>>>
>>> Заранее спасибо.
>>
>>
>>
>> Добавте в LIBS -lstdc++
> 
> О! Пасибо! Сработало! А почему так? Была у нас прогга на cpp которая 
> использовала mysqllib - который вроде ж на c и без этой опции обходились 
> прекрасно?
> 

g++ включает libstdc++.so по умолчанию. gcc этого не делает ;)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Comm] compiling cpp and c files
  2004-10-22  9:36         ` Yuri N. Glibovetz
@ 2004-10-22  9:53           ` Alexey Morsov
  0 siblings, 0 replies; 10+ messages in thread
From: Alexey Morsov @ 2004-10-22  9:53 UTC (permalink / raw)
  To: community


Yuri N. Glibovetz wrote:

> g++ включает libstdc++.so по умолчанию. gcc этого не делает ;)
Спасибо - буду знать!

-- 
Всего наилучшего,
Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ"
Алексей Морсов
ICQ: 196766290
Jabber: Samurai@jabber.pibhe.com
http://www.ricom.ru
http://www.fondmarket.ru


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-10-22  9:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-21 13:04 [Comm] compiling cpp and c files Alexey Morsov
2004-10-21 15:39 ` Yuri N. Glibovetz
2004-10-22  6:33   ` Alexey Morsov
2004-10-21 15:42 ` Denis Kirienko
2004-10-22  6:32   ` Alexey Morsov
2004-10-22  9:02     ` Yuri N. Glibovetz
2004-10-22  9:23       ` Alexey Morsov
2004-10-22  9:36         ` Yuri N. Glibovetz
2004-10-22  9:53           ` Alexey Morsov
2004-10-21 19:28 ` scor

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git