Help on tbarcode11 library not working

Hi all.
I am C# developer
I want to use a barcode library I am used to work with in Windows through a wrapper library in linux too.

This Wrapper library should be cross platform but unfortunately still references the System.Drawing.Common based on libgdi+ that is considered deprecated.

So I am writing my own wrapper in order to paint the metadata using alternative libraries like
ImageSharp or SkiaSharp (or even skiasharp wrapped by Microsoft.Maui.Graphics)

My wrapper works great if compiled for windows running in windows but fails silently if i compile for linux_x64 and runs on my Ubuntu focal 20.04 Distribution under WSL2.

I’ve tried also on another WSL2 with Ubuntu 24.02, and also on a real installation of 24.04 on a server.

Always the same behoviour:
I set the data for the barcode (super simple based on an SDK example), i cal the function BCCreate, and then i ask the number of modules, and reports 0 modules.

With no modules generated, I get no callback calls for drawing bars or to get metadata.
But, using the commandline tool to generate a bitmap file with a barcode, the barcode is generated correctly (except for artefacts added by pourpose if we don’t apply the license information in the license.it file in “/usr/local/share/tbarcode11”).

I carefully checked the Marhalling of the functions are correct also for linux version of the native dynamic library (.so), and verified that the commands accepts data with no errors only if the marshalling is correct, and the callback to write the human readable text, works and provides the correct text

at the end I got a distribution of Open Suse Leap 15.6, and on that distrubution, fist I had to install the package of libicu as requested by the first try error reported, and then worked! The number of modules generated where non zero!

My test was compiled as an executable binary, single file and selfcontained (Net7.0)

The library in linux is installed by its official installer downloaded by the official page:
Download Linux Barcode Generator Software - TBarCode/X

and the library is found adding the path to LD_LIBRARY_PATH environment variable
( \usr\local\lib )

I’d like to know what’s wrong with that library or what I can do un my Ubuntu distribution to get the modules generated like on Suse.

here the function to get the modules count:
TBarCode Library 11: BCGetCountModules

and here the Developer guide where on chapter 7 there is a sample code to get up to BCCreate() with a simple barcode and be able to count the modules:
TBarCode Library

Ubuntu Version:
20.04 LTS, and 24.04 LTS

Desktop Environment (if applicable):
None, run under WSL or throug SSH on a server

Problem Description:
Barcode library is unable to generate modules

Relevant System Information:
RID linux_x64

Screenshots or Error Messages:
none

What I’ve Tried:
openSUSE Leap 15.6 distribution on WSL

I have an update.
I actually misunderstood the return type, it was a floating point double I’ve confused with a long integer.
I was self confident because windows library PInvoke seemed to work fine anyway, and other distribution returned non 0 value.
(after Ubuntu 20.04, 24.04 and Suse, I’ve tryed also Debian12, FedoraLinux42, and Also Ubuntu 18.04 and 22.04)
Fedora returned a negative value too… ok that was NOT normal!, there must be also a mistake of mine…
Now that I Know that modules are generated, now I must focus to make the callback working, but this need a license, I got a temporary one from the library support.

The mistery on why Ubuntu was the only to return always 0 remains.
I am Sorry for the mistake, but this lead me to join the community!
Thank you all!

If I understand you correctly, this is only partly solved?

By they way, we do not use Solved in the title to mark something.

Instead, use the checkbox in whichever post is relevant for the solution.

Thanks.

1 Like

Some Additional Info.

You don’t need the license to get callback to draw human readable texts.

You need the license to get callback to draw graphics or to get metadata (strings with succession of letters where each letter means a bar with a specific width)

The functions does not report errors if the license is not found or not correct, the function for custom drawing function just delays a little and does not call graphic callback.

The enum of the barcode product licensed has new special values for Linux version, that should be provided instead of the legacy ones calling the function to set the license

To legacy library and wrapper for windows (TBarcode SDK) is not the same product you use on Linux/Unix/MacOs (TBarcode/X), to use linux you need to purchase the license for “TBarcode/X”

Functions with strings are doubled in A (ansi) and W (wide, utf-16) version.
They exists also on linux but A us still ANSI/Latin (not UTF8) W version are UTF-32 and Microsoft dotnet does not have a StringMarshaller for UTF-32, you have to implement a custom one. You cannot simply use utf8 marshaller and sleep happy.

Functions that fetch error codes description and details, have strings parameters that have be marshalled in a different way, (with legacy DllImport with the ANSI versions you could pass a preallocated StringBuilder that gets filled with the output) With new reccommended ways (LibraryImport) you cannot pass Stringbuilder and you cannot use “out” or “ref” string parameters because does not work that way, the string data should be allocated by you (ref and out just allocates unmanaged memory for a pointer to the string data that can be changed by the called function)

Hope will help someone
Cheers.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.