What you describe as your solution is a little strange. But, to focus on the problem at hand. Do you create a Task/Virtual Channel* in your code?
It sounds like that's not the case, given the error message. Section 3 of the following document goes over creating tasks and virtual channels, including C code: Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications http://www.ni.com/product-documentation/2835/en/
*The difference between the two can be found in this document: