Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linking problems with VS compiler and ESQLC code

22 views
Skip to first unread message

Colin Hay

unread,
Jun 14, 2009, 9:04:21 AM6/14/09
to

My ESQLC program that I've been working on for a while builds fine using the
VS 2008 compiler using a makefile

After adding an Ingres routine to convert decimals to strings in C and
adding all the various include files that were also required
I was getting compile errors caused clashes with 3 functions - atoi(),
calloc() and free()
I was getting 'errors in stdlib.h - error C2375 - redefinition; different
linkage' errors

The Dec2Str routine includes stdlib.h which seems to be causing these
problems

I copied the prototypes definitions from stdlib.h (the Visual Studio C++
file) and pasted them into my .sc code thus:

_CRTIMP _CRTNOALIAS void __cdecl free(_Inout_opt_ void * _Memory);
_Check_return_ _CRTIMP _CRT_JIT_INTRINSIC int __cdecl atoi(_In_z_ const
char *_Str);
_Check_return_ _Ret_opt_bytecap_x_(_NumOfElements* _SizeOfElements) _CRTIMP
_CRT_JIT_INTRINSIC _CRTNOALIAS _CRTRESTRICT void * __cdecl calloc(_In_
size_t _NumOfElements, _In_ size_t _SizeOfElements);

This fixed the compile errors but then naturally enough I get unresolved
symbols:

_CM_AttrTab
_cmu_getutf8property
_CM_UTF8Bytes
_CM_isUTF8

caused by these declarations. What this the right thing to do ? Isn't UTF
Unicode - what is it trying to do ?!?

I also tried with Visual Studio 6 - in case VS 2008 was breaking Ingres
somewhere with the following declarations

_CRTIMP void __cdecl free(void *);
_CRTIMP int __cdecl atoi(const char *);
_CRTIMP void * __cdecl calloc(size_t, size_t);

Same problems ....

What do I need to get it all to compile and link ?

Karl & Betty Schendel

unread,
Jun 14, 2009, 2:05:03 PM6/14/09
to Ingres and related product discussion forum

On Jun 14, 2009, at 1:04 PM, Colin Hay wrote:

>
> My ESQLC program that I've been working on for a while builds fine
> using the
> VS 2008 compiler using a makefile
>
> After adding an Ingres routine to convert decimals to strings in C and
> adding all the various include files that were also required
> I was getting compile errors caused clashes with 3 functions - atoi(),
> calloc() and free()
> I was getting 'errors in stdlib.h - error C2375 - redefinition;
> different
> linkage' errors

Where are the original definitions?

When you say "adding an Ingres routine", are you talking about
copying one
of the Ingres CV routines? Are you calling the CL directly, or are you
using a copy of the routine from source?

>
> The Dec2Str routine includes stdlib.h which seems to be causing these
> problems
>
> I copied the prototypes definitions from stdlib.h (the Visual
> Studio C++
> file) and pasted them into my .sc code thus:
>
> _CRTIMP _CRTNOALIAS void __cdecl free(_Inout_opt_ void * _Memory);
> _Check_return_ _CRTIMP _CRT_JIT_INTRINSIC int __cdecl atoi
> (_In_z_ const

> char *_Str); ...

Bletch. Somewhere, baby Jesus is weeping...

>
> This fixed the compile errors but then naturally enough I get
> unresolved
> symbols:
>
> _CM_AttrTab
> _cmu_getutf8property
> _CM_UTF8Bytes
> _CM_isUTF8
>
> caused by these declarations.

I don't think those are caused by the declarations, they are routines
that
are part of the Ingres CL for character manipulation.

Karl


James K. Lowden

unread,
Jun 15, 2009, 8:47:21 PM6/15/09
to Ingres and related product discussion forum
Karl & Betty Schendel wrote:
> > I was getting 'errors in stdlib.h - error C2375 - redefinition;
> > different
> > linkage' errors
>
> When you say "adding an Ingres routine", are you talking about

(FWIW, I read that as, "I added calls to some Ingres functions".)

> > The Dec2Str routine includes stdlib.h which seems to be causing these
> > problems

No, including the *same* stdlib.h twice can't cause a redefinition error.
The compiler should report the complete file name and line numbers of the
conflicting declarations.

> Bletch. Somewhere, baby Jesus is weeping...

Not to mention Dennis Ritchie!

> > This fixed the compile errors but then naturally enough I get
> > unresolved
> > symbols:
> >
> > _CM_AttrTab
> > _cmu_getutf8property
> > _CM_UTF8Bytes
> > _CM_isUTF8
> >
> > caused by these declarations.

Redeclaration of functions don't "cause" linker errors. They conceal them
in the sense that the linker isn't invoked until compilation succeeds.

The linker errors are caused by not adding the library that implements
them to your linker inputs. From the Embedded SQL Companion Guide, that
looks to be libingres.lib. You can use Microsoft's objdump.exe to confirm
that it supplies those names.

HTH.

--jkl

John Dennis

unread,
Jun 16, 2009, 12:30:01 AM6/16/09
to Ingres and related product discussion forum
Colin has raised an issue with Tech Support. He was provided with the
code for CVpka() (plus the associated header files needed to make it
compile) so he could convert packed decimal datatypes to a string. When
I built his code I saw three unresolved externals: _CM_AttrTab,
_CM_UTF8Bytes and _CM_isUTF8 which are all external variables, but
without the original external definition they are undefined.

The code builds and links fine by adding a "#define GLOBALREF " before
all of the Ingres header files (that of course making those variables
now local) but whether it will run successfully is another story...

John

-----Original Message-----
From: info-ingr...@kettleriverconsulting.com
[mailto:info-ingr...@kettleriverconsulting.com] On Behalf Of
James K. Lowden
Sent: Tuesday, 16 June 2009 10:47 AM
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] Linking problems with VS compiler and ESQLC
code

Karl & Betty Schendel wrote:

> > I was getting 'errors in stdlib.h - error C2375 - redefinition;
> > different linkage' errors
>

> When you say "adding an Ingres routine", are you talking about

(FWIW, I read that as, "I added calls to some Ingres functions".)

> > The Dec2Str routine includes stdlib.h which seems to be causing
> > these problems

No, including the *same* stdlib.h twice can't cause a redefinition


error.
The compiler should report the complete file name and line numbers of
the conflicting declarations.

> Bletch. Somewhere, baby Jesus is weeping...

Not to mention Dennis Ritchie!

> > This fixed the compile errors but then naturally enough I get

> > unresolved
> > symbols:
> >
> > _CM_AttrTab
> > _cmu_getutf8property
> > _CM_UTF8Bytes
> > _CM_isUTF8
> >
> > caused by these declarations.

Redeclaration of functions don't "cause" linker errors. They conceal


them in the sense that the linker isn't invoked until compilation
succeeds.

The linker errors are caused by not adding the library that implements
them to your linker inputs. From the Embedded SQL Companion Guide, that
looks to be libingres.lib. You can use Microsoft's objdump.exe to
confirm that it supplies those names.

HTH.

--jkl

_______________________________________________
Info-Ingres mailing list
Info-...@kettleriverconsulting.com
http://www.kettleriverconsulting.com/mailman/listinfo/info-ingres


Andrew

unread,
Jun 23, 2009, 2:45:45 AM6/23/09
to Ingres and related product discussion forum
Hi All,

I am trying to create a csv file using Report Writer and hopefully when opened in Excel will display negative values inside round brackets.

Has anyone been successful in doing this? Any help would be greatly appreciated.

I have tried opening my csv file in Excel 2003 and 2007 and the best I get, so far, is a negative value in red - no brackets...

I have a feeling its more an Excel issue but someone might know the formula required.

Sample csv file:

.name x
.declare
    value = money not null

.query
    select yeah = date('today')
    from iitables

.noformfeeds
.pagelength 0

.header report
   .let value = -12345.00
   .pr value ('($$$$$$.nn)')
   .nl
   .pr '"', value ('($$$,$$$.nn)'), '"'
   .nl
   .pr '"', value ('((((,(((.nn)'), '"'
   .nl
   .pr value ('((((((((.nn)')
   .nl


Here is the content of my csv file...

($12345.00)
"($12,345.00)"
" (12,345.00)"
  (12345.00)


Double clicking on the file in windows starts excel and loads the file but the brackets are not displayed...

Regards,
Andrew.

Roy Hann

unread,
Jun 23, 2009, 4:56:38 AM6/23/09
to
Andrew wrote:

> Hi All,
>
> I am trying to create a csv file using Report Writer and hopefully when
> opened in Excel will display negative values inside round brackets.
>
> Has anyone been successful in doing this? Any help would be greatly
> appreciated.
>
> I have tried opening my csv file in Excel 2003 and 2007 and the best I
> get, so far, is a negative value in red - no brackets...
>
> I have a feeling its more an Excel issue but someone might know the
> formula required.

I think your feeling is correct. I think you need to use a custom
format, which would have to be done manually in Excel.

[snip]

> Double clicking on the file in windows starts excel and loads the file
> but the brackets are not displayed...

--
Roy

UK Ingres User Association Conference 2010 will be on Tuesday June 8 2010
Go to http://www.iua.org.uk/join to get on the mailing list.


OldSchool

unread,
Jun 23, 2009, 1:35:14 PM6/23/09
to

stand the problem on its head...enter -12 in a cell in the worksheet,
then set the format for the cell to number, and the format of negative
number to show parenthesis. save as a csv file. edit to see the
contents and should see a number as shown w/ lparen-value-rparen.
opening that same file in Excel will display the value preceded by a
minus sign. CSV doesn't appear to store "cell formatting" (as Excel
warns you w/ numerous disclaimers).

if you don't need to do math on the field, then preceding (<value>)
with a single-quote will cause excel to read that as text and maintain
the parens. otherwise you may be forced into simply writing the
values to your file and reapplying the formatting of numerics as
required.

James K. Lowden

unread,
Jun 25, 2009, 11:45:30 PM6/25/09
to Ingres and related product discussion forum
Roy Hann wrote:
>
> > I have a feeling its more an Excel issue but someone might know the
> > formula required.
>
> I think your feeling is correct. I think you need to use a custom
> format, which would have to be done manually in Excel.

Another option: Keep a spreadsheet all nicely formatted with formula
references to another file: your csv file. With a little cleverness,
maybe a macro, the data filename can be dynamic, if that matters.

HTH.

--jkl

Andrew

unread,
Jun 30, 2009, 12:29:06 AM6/30/09
to Ingres and related product discussion forum
I tried many things and appreciated all the suggestions.

But due to the various requirements I will have to look into generating
an ascii style of file for Excel - file extension .slk (SYLK files)

Hopefully I will be able to achieve what I need with this...

Regards,
Andrew.

James K. Lowden wrote:


> Roy Hann wrote:
>
>>> I have a feeling its more an Excel issue but someone might know the
>>> formula required.
>>>
>> I think your feeling is correct. I think you need to use a custom
>> format, which would have to be done manually in Excel.
>>
>

> Another option: Keep a spreadsheet all nicely formatted with formula
> references to another file: your csv file. With a little cleverness,
> maybe a macro, the data filename can be dynamic, if that matters.
>
> HTH.
>
> --jkl
>

Richard Harden

unread,
Jun 30, 2009, 5:44:49 AM6/30/09
to Ingres and related product discussion forum

Hi Andrew,

 

I Have just played around with a csv file with various rows in it, opening it with excel 2007

 

CSV File Contents

"String Value","Number"

"One",1

"Two",2

"Minus 1",-1

"Minus 2",(2)

"last Line",9999

 

Excel Results

String Value

Number

One

1

Two

2

Minus 1

-1

Minus 2

-2

last Line

9999

 

 

Whilst excel seems to understand the brackets, it still displays the numbers in the general format

 

Perhaps the best option is to use a macro on open to import the csv file and apply the “#,##0;(#,##0)” formatting to the number columns that you want displayed with () around the negative numbers

 

The other option I tried was to create a spreadsheet in the required format with column headers etc, then formatted the number columns using “#,##0;(#,##0)”, then on the first row and column

Below the header I imported external data (after going through the basic import questions (delimiters, text/general etc) I got the data in and the result seems to be what you are after

(for this test I did remove the column headers from the csv file.

 

 

String Values

Numbers

Positive 1

1

Positive 2

2

Negative 1

(1)

Negative 2

(2)

Last Line

999

 

So it will probably be possible to create a macro that on opening the spreadsheet it automatically imports the csv file.

 

 

Hope this helps

 

Dic Harden.

 

 

-----Original Message-----
From: info-ingr...@kettleriverconsulting.com [mailto:info-ingr...@kettleriverconsulting.com] On Behalf Of Andrew
Sent: Tuesday, 30 June 2009 4:29 p.m.
To: Ingres and related product discussion forum

Subject: Re: [Info-Ingres] Report writer - csv with brackets around negative values...

 

I tried many things and appreciated all the suggestions.

 

But due to the various requirements I will have to look into generating

an ascii style of file for Excel - file extension .slk (SYLK files)

 

Hopefully I will be able to achieve what I need with this...

 

Regards,

Andrew.

 

James K. Lowden wrote:

> Roy Hann wrote:

>  

>>> I have a feeling its more an Excel issue but someone might know the

>>> formula required.

>>>      

>> I think your feeling is correct.  I think you need to use a custom

>> format, which would have to be done manually in Excel.

>>    

> 

> Another option: Keep a spreadsheet all nicely formatted with formula

0 new messages