umz
umz

Reputation: 59

How to manage automatically generated c-files from matlab coder?

I have an existing dll with multiple functions, let's call it mylib. I decided to use matlab coder to help me write my c-files. These c-files are compiled and linked to generate mylib using VS 2015.

So I test this theory i first started by converting funcA.m to funcA.c using matlab coder ver 3.4 (R2017b) . funcA is ust a simple mathematical function. Then I compiled and linked all the c-files generated by matlab coder to include funcA inside mylib. And this worked perfectly. Meaning, funcA which was originally a m-file was compiled, linked to mylib and had produced the accurate results.

The problem arises when I use matlab coder to generate my second function. Let's call the second function -> funcB

After converting funcA.m to funcA.c, matlab coder had generated other c-files which includes xgeqp3.c and xnmr2.c and its corresponding header files. I consider them non-readable by humans because they were automatically generated by matlab coder and it is not human friendly to read them as you can tell by the name of the c-files. However, they are being called by funcA so they have to be compiled into the library as well.

These matlab generated c-file caused me problems because when I converted funcB.m to funcB.c, it had also generated xgeqp3.c and xnmr2.c. Although the files names are identical, its contents are different, with different formal parameters and of course different c-codes, even though they have the same function name and file name.

So the same library cannot contain these two functions generated by matlab coder because the declarations for xgeqp3.c and xnmr2.c contradicts. I'm sure other people might have the same problem. Is there a way I can manually name the extra c-files generated my matlab coder so that I can avoid such duplicate names? Or is there a way I can manage the c-files with duplicate names but different codes? The easier option is to create separate libraries for the two functions. But I want all my mathematical functions to be in the same library.

How should I handle this situation? I'm open to new ideas. Thank you in advance.

Upvotes: 0

Views: 326

Answers (1)

ThP
ThP

Reputation: 2342

You should generate the c code together for all the functions that you want compile in the same dll.
If you are using command-line you should do:

codegen funcA, funcB  

If you are using the Matlab Coder App, add both functions as entry point files.

Upvotes: 2

Related Questions