First runs with Flex

Hi,

I’m trying to use the Flex library (The Nvidia one not the bison/lex/flexx/yacc one) I’m just trying the demo in the documentation and I keep getting told that NULL does not exist. Is there some lib that defines this or perhaps is there a standard definition that Nvidia uses or the Cuda libraries define for this ?

I’m afraid I’m originally from a Matlab/python background and have not had much opportunity to fiddle with C and it’s relations, though I’ve read up somewhat.

If it helps any I’ve done the following :

Create a new blank/empty project solution in MS visual studio.
Point it towards the flex library and compiled.

If I must pass the example code from the manual or provide a ZIP or something please let me know.

Regards,

Carel

Hi again,

It seems the problem is fixed on the 0.9 version of Flex.

To use the library create a blank project, File>New>Visual C++>Empty Project and got to the popup under PROJECT>{PROJECT} Properties.

Select the submenu, Configuration properties>VC++ Directories, and include the following paths under the following directories :

Path Attribute
…\flex\bin Executable Directories
…\flex\include Include Directories
…\flex\lib Library Directories

Next go to the linker, Linker>Input, and include ‘flexDebug_64.dll’ or ‘flexRelease_64.dll’ under Additional Dependencies. Also under Additional Library Directories include a link to …\flex\lib.

It seems you also have to change the setting Build>Configuration Manager to allow for 64 bit. Create this under active solution platforms.

Finally copy the FlexRelease/Debug dll to …{PROJECT}\x64\Debug. I suspect there will be a similarly named folder for releasess.

The code still requires two modifications. The example in the document refers to two variables that are not defined the first is called finished, a bool that needs to be specified the second is a timer provided by the flex library. In version 0.8 one could supposedly set this timer to NULL, in version 0.9 VS is happy if you simply use a flextimer reference. The modified code is given below.

#include <flex.h>
    
    const int maxParticles = 65536;
    const int maxDiffuse = 0;
    
    int main(void)
    {
    	flexInit();
    	FlexSolver* solver = flexCreateSolver(maxParticles, maxDiffuse);
    	bool finished = false;
    	FlexTimers timer;
    
    	while (!finished)
    	{
    		const float dt = 1.0f / 60.0f;
    
    		// tick solver with one sub-step
    		flexUpdateSolver(solver, dt, 1, &timer);
    	}
    
    	flexDestroySolver(solver);
    	flexShutdown();
    
    	return 0;

A further development. I tried compiling the FlexDemo on my machine. It howeevr keeps throwing an R6010 Error, abort() is called. Would any one have an idea why this might be ?