T O P I C R E V I E W |
couturier |
Posted - 08/19/2020 : 06:27:11 AM Origin Ver. and Service Release (Select Help-->About Origin):2020b Operating System:win10 64
I've built a series of 8 Apps that work together - 1 App is using 3 files: say main.c, analysis.c and reports.c main.c is using functions in analysis.c and reports.c main.c starts with #include "reports.c" analysis.c has analysis functions reports.c is used for building various reports, and is using analysis.c. It starts with #include "analysis.c"
- the 7 other Apps have their own main.c, AND are using analysis.c and reports.c from 1st App The main code of all those 7 Apps starts with #include "..\1st App\reports.c"
This is how I did, with my global misunderstanding of C language, but maybe there's a much better way ?
Now, I want to share those Apps around but I don't want users to see the source code. I think sharing .op files is better because building will be much faster (and I'm 100% sure I will forget password in .ocz files).
I could successfully generate .op files with @OCSB=0; but then, how can I include those .op files into main.c (I mean #include "reports_64.op" doesn't work) ?
Thanks |
9 L A T E S T R E P L I E S (Newest First) |
couturier |
Posted - 08/20/2020 : 03:40:10 AM Perfect |
cpyang |
Posted - 08/19/2020 : 6:57:21 PM You should only load your main OC file, but need to indicate to auto load dependents.
run.LoadOC("%@ACloud ASP\ASP", 16)
See https://www.originlab.com/doc/Quick-Help/Load-Call-Functions
CP
|
couturier |
Posted - 08/19/2020 : 4:59:22 PM Thanks everybody for the help and explanations, things progress a bit.
I still have that "function body could not be located during linking" error.
if ( !run.LoadOC("%@ACloud ASP\ASP_Utils", 2) && !run.LoadOC("%@ACloud ASP\ASP", 2) ) ASP_PSQS(); will give error
If I use the build button in code builder, everything compile and link and I can use the App
|
cpyang |
Posted - 08/19/2020 : 2:15:26 PM
bool ASP_Build_Report(string strJson, int& back, int& forth, int SHN = 1, int newbook = 1)
You need to remove the defaults in the function implementation. Defaults can be in prototypes only.
CP
|
couturier |
Posted - 08/19/2020 : 1:53:50 PM I had many errors so I tried so simplify things and I merged the 2 common files The main App can work on its own (without the others installed)
It has: ASP.ogs:
if ( !run.LoadOC("%@ACloud ASP\ASP_Utils", 2) && !run.LoadOC("%@ACloud ASP\ASP", 2) ) ASP_PSQS(); ASP.c which starts with #include "ASP_Utils.h"
ASP_Utils.h: all functions prototypes
ASP_Utils.c: starts with #include "ASP_Utils.h" and has all functions bodies
When I try to compile, I get those 2 errors:
error: C:\Users\acouturier\AppData\Local\OriginLab\Apps\Cloud ASP\ASP.c(1102) :Error, Function ASP_laboSEP@_LBAABAAALBAABAAA was called, but its body could not be located during linking.
ASP_laboSEP prototype is located in ASP_utils.h ASP_laboSEP body is located in ASP_utils.c
now that function is overloaded (not sure it is the correct term) it appears as: string ASP_laboSEP() void ASP_laboSEP(vector<string>& vlab, vector<string>& vstud)
could it be the issue ?
And 2nd error: C:\Users\acouturier\AppData\Local\OriginLab\Apps\Cloud ASP\ASP_Utils.c(309) :Error, function declaration does not match previous declaration of the same function.
function prototype looks like: bool ASP_Build_Report(string strJson, int& back, int& forth, int SHN = 1, int newbook = 1); function body looks like
bool ASP_Build_Report(string strJson, int& back, int& forth, int SHN = 1, int newbook = 1)
{
some code here;
}
Am I doing any beginner's mistake ? |
Chris D |
Posted - 08/19/2020 : 12:25:17 PM Antoine,
Additionally are you still getting the security issues once you moved away from using OP files?
Thanks, Chris Drozdowski Originlab Technical Support
|
Chris D |
Posted - 08/19/2020 : 11:48:50 AM Hi Antoine,
If you want to hide code from users, create OCZ files instead of C files. Header files cannot be encrypted but because the only contain function prototypes perhaps it isn't so important they are can be human readable.
See: https://www.originlab.com/doc/Quick-Help/Encrypt-Origin-C-File https://www.originlab.com/doc/CodeBuild/Working-With-Files#Encrypting_the_Source_File
Thanks, Chris Drozdowski Originlab Technical Support
|
couturier |
Posted - 08/19/2020 : 11:28:50 AM Thanks
I was suspecting that, but wanted to be sure before creating a header file for several hundreds of functions.
I've created the opx and I have a few issues: - cannot install the opx on any other computer. I have an error message saying that installation is not allowed, contact admin First tim I see that
- in my computer, I was expecting much faster compiling with op files. It looks the opposite. Plus, it looks like files are compiled everytime I call the App (I mean, it takes quite a while before the dialog shows) With regular .c files, it happens at first launch only |
Castiel |
Posted - 08/19/2020 : 06:57:23 AM quote: Originally posted by couturier
Origin Ver. and Service Release (Select Help-->About Origin):2020b Operating System:win10 64
I've built a series of 8 Apps that work together - 1 App is using 3 files: say main.c, analysis.c and reports.c main.c is using functions in analysis.c and reports.c main.c starts with #include "reports.c" analysis.c has analysis functions reports.c is used for building various reports, and is using analysis.c. It starts with #include "analysis.c"
- the 7 other Apps have their own main.c, AND are using analysis.c and reports.c from 1st App The main code of all those 7 Apps starts with #include "..\1st App\reports.c"
This is how I did, with my global misunderstanding of C language, but maybe there's a much better way ?
Now, I want to share those Apps around but I don't want users to see the source code. I think sharing .op files is better because building will be much faster (and I'm 100% sure I will forget password in .ocz files).
I could successfully generate .op files with @OCSB=0; but then, how can I include those .op files into main.c (I mean #include "reports_64.op" doesn't work) ?
Thanks
Instead of including the source code file, you should in your .c files include the header file.
Let's say, there is a function in analysis.c like this:
double foo(double x, double y) then create an analysis.h file with:
double foo(double x, double y);
In your main.c:
#include "analysis.h"
/*
...
double f = foo(x, y);
...
*/
Prior to building in Code Builder, you should load the op manually:
run.loadoc(<path-to-the-op-file>)
In practice, create and include the header files rather than the source code.
------------------------------------------
Be The Change
You Want To See
In The World
------------------------------------------
|
|
|