473,395 Members | 1,956 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,395 software developers and data experts.

Compiling LGPL C source in Visual C++ FILE vs. Cfile?

Had a recent opportunity to grab some MP2 audio encoder source to use
in a little utility I am writing in support of a Korg portable
multitrack digital recorder. It is LGPL C and my project is Visual
C++. A few problems, e.g.

variables using C++ keywords, e.g. new and class - OK that was easily
solved.

biggest problem is file I/O, the C code uses lots of

FILE *fp;

fp = fopen("googble.mp2","rb);

etc.

Do I really have to go thru all the code and say CFile fp;
fp.Open(etc.etc.), or is there some way to get the original FILE
pointer method to work? I just get compile errors whenever this is
encountered.

For the record I write a computer program every 2 or 3 years so I am
pretty rusty on what may be a simple problem. I hope.

I am a bit daunted because FILE and associated routines are used ALL
over this code, and given it is open source I'd like to avoid major
mods if possible.

Thanks,

Gary
Jul 19 '05 #1
17 4439

"Gary" <fa***********@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
Had a recent opportunity to grab some MP2 audio encoder source to use
in a little utility I am writing in support of a Korg portable
multitrack digital recorder. It is LGPL C and my project is Visual
C++. A few problems, e.g.

variables using C++ keywords, e.g. new and class - OK that was easily
solved.

biggest problem is file I/O, the C code uses lots of

FILE *fp;

fp = fopen("googble.mp2","rb);

etc.

Do I really have to go thru all the code and say CFile fp;
fp.Open(etc.etc.), or is there some way to get the original FILE
pointer method to work? I just get compile errors whenever this is
encountered.

For the record I write a computer program every 2 or 3 years so I am
pretty rusty on what may be a simple problem. I hope.

I am a bit daunted because FILE and associated routines are used ALL
over this code, and given it is open source I'd like to avoid major
mods if possible.


Leave the code alone. Visual C++ is capable of compiling
in 'C mode'. Don't try to 'translate' to C++, you're just
asking for trouble. If I recall correctly, all you need
is a .c extension on your source file to make VC++ compile
as C instead of C++. See your documentation.

-Mike
Jul 19 '05 #2
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<Vr*****************@newsread3.news.pas.earth link.net>...
Leave the code alone. Visual C++ is capable of compiling
in 'C mode'. Don't try to 'translate' to C++, you're just
asking for trouble. If I recall correctly, all you need
is a .c extension on your source file to make VC++ compile
as C instead of C++. See your documentation.

-Mike


Mike, what I forgot to mention is that I'm incorporating this code
into a Visual C++ project that already IS in C++. I read some
articles on mixing C and C++ code which suggested that converting all
C source to C++ might be easier. The interface between the C++ code
and the MP2 encoder can, however, be limited to about 6 function
calls.

I know that C++ when it generates labels goes way beyond what a C
compiler would do... any handy hints on calling C code from within a
C++ program? E.g. I don't know whether I can compile a set of obj
files as C, another set as C++ and link them all together, or should I
make a dll for the C code, or a static library, etc. etc.

Thanks for any hints!

Gary
Jul 19 '05 #3
Gary wrote:

Mike, what I forgot to mention is that I'm incorporating this code
into a Visual C++ project that already IS in C++. I read some
articles on mixing C and C++ code which suggested that converting all
C source to C++ might be easier.


As you've seen, that's not necessarily true. It's often better to not
mess with working code.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 19 '05 #4

Gary wrote:
[...]
make a dll for the C code, or a static library, etc. etc.


Static library is, in effect, prohibited by brain-damaged LGPL (unless
you're quite happy to infect your own work). DLL is your only practical
choice... and, BTW, you might STILL be in violation of LGPL silliness.
I suggest that you should rather boycott the [L]GPL'd stuff if you can.

Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
and technically sound reciprocity provision (aka "share alike").

regards,
alexander.
Jul 19 '05 #5
Alexander Terekhov wrote:
Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
and technically sound reciprocity provision (aka "share alike").


What does this actually mean?

--
WW aka Attila
Jul 19 '05 #6

White Wolf wrote:

Alexander Terekhov wrote:
Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
and technically sound reciprocity provision (aka "share alike").


What does this actually mean?


Linking with libraries (aggregating components) doesn't create a
derivative work. It creates a collective work. Its constituent
parts can be distributed together ("static linking") or separately
("dynamic linking"). Non-[L]GPL "share alike" licenses do NOT try
to exercise the right to control the distribution of collective
works based on the "share alike"-licensed stuff. Fair and *non*-
discriminating "share alike" is basically the following:

http://creativecommons.org/licenses/by-sa/1.0/legalcode

see section 4.

<quote>

The above applies to the Work as incorporated in a Collective
Work, but this does not require the Collective Work apart from
the Work itself to be made subject to the terms of this License.

</quote>

and

<quote>

The above applies to the Derivative Work as incorporated in a
Collective Work, but this does not require the Collective Work
apart from the Derivative Work itself to be made subject to the
terms of this License.

</quote>

And, BTW, [L]GPL silliness is nicely illustrated here:

http://gcc.gnu.org/onlinedocs/libstd...o/license.html

regards,
alexander.
Jul 19 '05 #7
"White Wolf" <wo***@freemail.hu> writes:
Alexander Terekhov wrote:
Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
and technically sound reciprocity provision (aka "share alike").


What does this actually mean?


It means Terekhov is completely off-topic.
Jul 19 '05 #8
Sorry I earlier posted a stupid question answered in the FAQ.

The approach I will try is to compile the C code as-is to a static
LIB.

Then link to this from my VC++ code.

Header file will contain references to functions in the LIB as 'extern
"C" f(...)' etc.

If that doesn't work I'll be back!
Jul 19 '05 #9
Sorry I earlier posted a stupid question answered in the FAQ.

The approach I will try is to compile the C code as-is to a static
LIB.

Then link to this from my VC++ code.

Header file will contain references to functions in the LIB as 'extern
"C" f(...)' etc.

If that doesn't work I'll be back!
Jul 19 '05 #10

llewelly wrote:

"White Wolf" <wo***@freemail.hu> writes:
Alexander Terekhov wrote:
Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
and technically sound reciprocity provision (aka "share alike").


What does this actually mean?


It means Terekhov is completely off-topic.


A sort of "technical" aspects of C++ code licensing (ability to
use AND distribute collective works including both closed-source
and "share alike" libraries/components/parts) is completely *ON*
topic here.

regards,
alexander.
Jul 19 '05 #11
"Gary" <fa***********@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<Vr*****************@newsread3.news.pas.earth link.net>...
Leave the code alone. Visual C++ is capable of compiling
in 'C mode'. Don't try to 'translate' to C++, you're just
asking for trouble. If I recall correctly, all you need
is a .c extension on your source file to make VC++ compile
as C instead of C++. See your documentation.

-Mike


Mike, what I forgot to mention is that I'm incorporating this code
into a Visual C++ project that already IS in C++.


C and C++ can be linked together, with some 'help' at
the source code level.
I read some
articles

Which articles? Many if not most available literature about
C++, especially on the 'net, is poor quality if not simply
incorrect.
on mixing C and C++ code which suggested that converting all
C source to C++ might be easier.

"Might" is often a long way from "is." :-) With certain scenarios,
that advice might :-) be valid, but I recommend against
taking it as a 'general' rule. One of my 'guiding principles'
is the less code you need to touch, the less you will break. :-)
The interface between the C++ code
and the MP2 encoder can, however, be limited to about 6 function
calls.

I know that C++ when it generates labels goes way beyond what a C
compiler would do...
Name mangling.
any handy hints on calling C code from within a
C++ program?
Look up:

extern "C"
E.g. I don't know whether I can compile a set of obj
files as C, another set as C++ and link them all together,
Yes, you can.
or should I
make a dll
A DLL won't help with your questions.
for the C code, or a static library,
A library won't help with your questions (but might make
life easier for builds once you get the source code straightened out.)
etc. etc.

Thanks for any hints!

// cfile.c -- compile as C
#include <stdio.h>
void foo(void)
{
puts("Hello");
}

// cdecls.h -- #include in cpp file below

extern "C"
{
void foo(void);
}
// (This could have been done directly in cpp file below,
// but this way retains 'modularity' and allows for
// better control when adding more declarations, and
// doesn't clutter up the main code with 'messy details'.


// cppfile.cpp -- compile as C++

#include "cdecls.h"

int main()
{
foo();
return 0;
}

Linker should be able to resolve names.

-Mike

Jul 19 '05 #12
Alexander Terekhov wrote:
[SNIP]
And, BTW, [L]GPL silliness is nicely illustrated here:

http://gcc.gnu.org/onlinedocs/libstd...o/license.html


Danke!

--
WW aka Attila
Jul 19 '05 #13
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<ax*****************@newsread3.news.pas.earth link.net>...
"Gary" <fa***********@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
I read some
articles

Which articles? Many if not most available literature about
C++, especially on the 'net, is poor quality if not simply
incorrect.


Marshall Cline's C++ FAQ Lite, I got the impression that some in this
NG view it as some sort of holy reference?

Anyway I know that each situation is unique and I will probably waste
a fair amount of time finding the right solution. This is what I get
for NOT being a professional programmer and forgetting a lot of stuff
in between writing programs.
any handy hints on calling C code from within a
C++ program?


Look up:

extern "C"


I thank you for your detailed and lenghty reply. I'll let you know
how it goes.
Jul 19 '05 #14
"Gary" <fa***********@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<ax*****************@newsread3.news.pas.earth link.net>...
"Gary" <fa***********@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
I read some
articles

Which articles? Many if not most available literature about
C++, especially on the 'net, is poor quality if not simply
incorrect.


Marshall Cline's C++ FAQ Lite, I got the impression that some in this
NG view it as some sort of holy reference?


I and most consider it to be quality C++ literature, as well
as is the hardcopy book form, which covers much more material.
I'd stop short of calling it 'holy' however (except perhaps
when it evokes a "holy sh*t!' I didn't know that!" :-) )

I was only warning you about the plethora of wrong information
that is out there on the web. You apparently are already
cautious enough to filter the material before relying upon it.


Anyway I know that each situation is unique
Each specific one, yes. But what you're asking about
(linking C++ code with C), is quite common.
and I will probably waste
a fair amount of time finding the right solution.
The right solution is to use extern "C"
No need to waste any more time.

This is what I get
for NOT being a professional programmer and forgetting a lot of stuff
in between writing programs.
It's no crime to practice programming as a hobby instead
of a profession. And even as a professional, I often
forget things too, which is why I always keep reference
material close at hand.
any handy hints on calling C code from within a
C++ program?

What I showed you should be all you need.

Look up:

extern "C"


I thank you for your detailed and lenghty reply. I'll let you know
how it goes.


Good luck!

-Mike
Jul 19 '05 #15
On Thu, 18 Sep 2003 19:59:52 +0200, Alexander Terekhov
<te******@web.de> wrote in comp.lang.c++:

llewelly wrote:

"White Wolf" <wo***@freemail.hu> writes:
Alexander Terekhov wrote:
> Academic style licensing (BSD/MIT/AFL/etc.) aside for a moment, stick
> with OFL'd/IPL'd/CPL'd/and-alike-'d stuff with fair and both legally
> and technically sound reciprocity provision (aka "share alike").

What does this actually mean?


It means Terekhov is completely off-topic.


A sort of "technical" aspects of C++ code licensing (ability to
use AND distribute collective works including both closed-source
and "share alike" libraries/components/parts) is completely *ON*
topic here.


....if and only if you can provide a citation from the ISO C++ standard
that defines any of the following:

"licensing"
"distribute"
"closed-source"
"collective works"
"components"
"parts"

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 19 '05 #16

Jack Klein wrote:
[...]
and "share alike" libraries/components/parts) is completely *ON*
topic here.


...if and only if you can provide a citation from the ISO C++ standard


Says who? I reasonably consider it "of general interest to the worldwide
C++ community" and THAT makes it "on-topic" even on c.l.c++.mod, buddy.

regards,
alexander.
Jul 19 '05 #17
Alexander Terekhov wrote:
Jack Klein wrote:
[...]
and "share alike" libraries/components/parts) is completely *ON*
topic here.


...if and only if you can provide a citation from the ISO C++
standard


Says who? I reasonably consider it "of general interest to the
worldwide C++ community" and THAT makes it "on-topic" even on
c.l.c++.mod, buddy.


Making friends again? ;-) BTW c.l.c++.mod is less restrictive than this
newsgroup. :-)

--
Attila aka WW
Jul 19 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jakov | last post by:
Ok there are some issues about LGPL licence. I am not a lawyer, and reading LGPL licence is making me confused. This is my problem. I have woking on some commercial application, all the software...
6
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...
5
by: David Jacques | last post by:
I have to write a console application which will fetch a zip on a daily basis. This zip file is hotlinked in a web page. The name of this .zip file will change every day. I've been able to start...
3
by: sredd01 | last post by:
Hello, Please look the code below where I am reading the first 2,2,4 bytes from a binary file using two methods. I am getting a wierd (wrong) output with ifstream and memcpy method, but get the...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
1
by: KevinGPO | last post by:
My application was developed under Visual C++ 6.0, ATL, MFC & PlatformSDK Feb2003 (the last VC6 compatible version). I am wondering if PlatformSDK Feb2003 is compatible with Visual Studio.NET...
9
by: Hollywood | last post by:
Hello members of the comp.lang.c++, My log file is made of a set of 1000 following lines kind: 21/09/07 13:49:56,MW.SET.D_IGLS,2.000000 21/09/07 13:49:56,MW.SET.GNP_NT,7.000000 ..... ...
4
rajiv07
by: rajiv07 | last post by:
Hi To all, I have a script for downloading file from the server.The Problem is when i try to download WMA file it get download but it is not playing.when i try to play this file in Windows Media...
13
by: sachin | last post by:
Hi, Is it possible to do something like this: unsigned char arr = { #include "cFile.c" } I need that C source file cFile.c to compile and its binary output to include in array.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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,...

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.