OpenBD / openbd-core

The original open source Java powered GPL CFML runtime engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFX/C++ info?

MFernstrom opened this issue · comments

There's a C project I'd like to try integrating with OpenBD, and from what I see there looks to be support for that using CFX.

I've never used it, and the Adobe pages I see mention registering the tags using the administrator.

Does C/C++ work with OpenBD, and is there some info somewhere about how to implement an example?

I do see the CFX_TestTag.cpp example in the native directory but I'm not sure what to do with it to be honest.

I've placed it in customtags/native/hello.cpp and added this mapping in the bluedragon.xml

<nativecustomtags>
    <mapping name="cfx_nativebluedragonhello">
      <function>ProcessTagRequest</function>
      <keeploaded>true</keeploaded>
      <name>cfx_nativebluedragonhello</name>
      <displayname>CFX_HW</displayname>
      <module>/WEB-INF/customtags/native/hello.cpp</module>
      <description>A simple C++ CFX tag example</description>
    </mapping>
  </nativecustomtags>

When I call it with <cfx_nativebluedragonhello> I get this error UnsatisfiedLinkError invoking CFXNativeLib method

Not sure if there's any more setup I need to do? I do have GCC/Clang installed.

Ultimately I'd like to not have a cfx_ tag but a regular cfscript function which runs C/C++, not sure if that's doable.

I did some CFX tags in the past and I can have a look. Meanwhile i mainly do Java CFX but i remember i did also C. Something i had difficulty was with 32 and 64 bit. The CFX tags I wrote few weeks ago in Java for JDO i did not registered, i just compiled and threw the class files into classes dir.

My goal is to implement libsodium, preferably I can implement it within the engine somehow, but if I can't I'll see if I can create a wrapper as a plugin and have it as a requirement.

It only works if I can create functions to be called, not just self contained tags, which to me looks like what CFX achieves.

True. Everything needs to be in one single call. There is no process or resource alive when the cfx tag is finished. Usually you would supply parameters as arguments and store result in a query or parameter. May be cfscript and a java component. ( Or even JNI? Not sure if possible at all.)

while reading your post again i understand you did NOT compile the cpp. Prior to use a CFX written in C/C++, the source must be compiled into a dll (Windows) or so (Linux).

I quickly tried one of the examples in com/naryx/tagfusion/cfx/native:

gcc -c BlueDragonHello.cpp

gcc -shared -o BlueDragonHello.so BlueDragonHello.o

mkdir ~/Downloads/jetty-openbd/www/WEB-INF/customtags

cp BlueDragonHello.so ~/Downloads/jetty-openbd/www/WEB-INF/customtags/

And this is the section in bluedragon.xml

<nativecustomtags>
    <mapping name="cfx_nativebluedragonhello">
      <function>ProcessTagRequest</function>
      <keeploaded>true</keeploaded>
      <name>cfx_nativebluedragonhello</name>
      <module>/WEB-INF/customtags/BlueDragonHello.so</module>
      <displayname>CFX_NativeBlueDragonHello</displayname>
      <description>A simple C++ CFX tag example</description>
    </mapping>
  </nativecustomtags>

my test page contains the tag <cfx_nativebluedragonhello/>

The output is:

Hello! Welcome to BlueDragon from a C++ CFX tag.

Thanks dtsw, that's a great example for how to use CFX.