First i make Aquila by Cmake
and then open the Aquila.sln file that generated by Cmake
and then from build menu and batch build check the
Aquila Debug Win32 Debug|Win32
Aquila Release Win32 Release|Win32
and generate Aquila.lib
and added this library and .h files in my solution for running the example but I have this error:
Error 1 error LNK2019: unresolved external symbol _cdft referenced in
function "public: virtual class std::vector,class std::allocator >
__thiscall Aquila::OouraFft::fft(double const * const)" (?fft#OouraFft#Aquila##UAE?AV?$vector#V?$complex#N#std##V?$allocator#V?$complex#N#std###2##std##QBN#Z) C:...\aquila\Aquila.lib(OouraFft.obj)
Then i change Runtime Library from Multi threaded debuge DLL (/MDd) to
Multi threaded debuge (/MTd)
but have this error: Error 1 error LNK2038: mismatch detected for
'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value
'MTd_StaticDebug' in
aquila.obj C:...\aquila\Aquila.lib(SignalSource.obj)
Aquila example
#include "aquila/aquila.h"
#include "stdafx.h"
int main()
{
// input signal parameters
const std::size_t SIZE = 64;
const Aquila::FrequencyType sampleFreq = 2000, f1 = 125, f2 = 700;
Aquila::SineGenerator sine1(sampleFreq);
sine1.setAmplitude(32).setFrequency(f1).generate(SIZE);
Aquila::SineGenerator sine2(sampleFreq);
sine2.setAmplitude(8).setFrequency(f2).setPhase(0.75).generate(SIZE);
auto sum = sine1 + sine2;
Aquila::TextPlot plot("Input signal");
plot.plot(sum);
// calculate the FFT
auto fft = Aquila::FftFactory::getFft(SIZE);
Aquila::SpectrumType spectrum = fft->fft(sum.toArray());
plot.setTitle("Spectrum");
plot.plotSpectrum(spectrum);
return 0;
}
Is there any one cane help me????
If you use aquila 3.0, after building aquila with cmake, Ooura_fft.lib must be in aquila-build/lib/Debug/Ooura_fft.lib. You have to link it to your project.
Related
I am trying to create a CUDA + C++ project. Basically a .cpp project that calls for some CUDA kernel. So I simply followed the example here, which basically adds two vectors. The kernel does the summation job:
http://blog.norture.com/2012/10/gpu-parallel-programming-in-vs2012-with-nvidia-cuda/
Here is the code,
#include <iostream>
#include "cuda_runtime.h"
#include "cuda.h"
#include "device_launch_parameters.h"
using namespace std;
__global__ void saxpy(int n, float a, float *x, float *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = a*x[i] + y[i];
}
int main(void)
{
int N = 1<<20;
float *x, *y, *d_x, *d_y;
x = (float*)malloc(N*sizeof(float));
y = (float*)malloc(N*sizeof(float));
cudaMalloc(&d_x, N*sizeof(float));
cudaMalloc(&d_y, N*sizeof(float));
for (int i = 0; i < N; i++) {
x[i] = 1.0f;
y[i] = 2.0f;
}
cudaMemcpy(d_x, x, N*sizeof(float), cudaMemcpyHostToDevice);
cudaMemcpy(d_y, y, N*sizeof(float), cudaMemcpyHostToDevice);
// Perform SAXPY on 1M elements
saxpy<<<(N+255)/256, 256>>>(N, 2.0, d_x, d_y);
cudaMemcpy(y, d_y, N*sizeof(float), cudaMemcpyDeviceToHost);
float maxError = 0.0f;
for (int i = 0; i < N; i++)
maxError = max(maxError, abs(y[i]-4.0f));
cout << "Max error: " << maxError;
}
When I built I got this error:
1>------ Rebuild All started: Project: CUDATest001, Configuration: Debug x64 ------
1> CUDATestZeroZeroOne.cpp
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol threadIdx
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol blockIdx
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol blockDim
1>D:\Projects\CUDATest001\x64\Debug\CUDATest001.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
If the line saxpy<<<(N+255)/256, 256>>>(N, 2.0, d_x, d_y); is commented out, then this error appeared:
1>------ Rebuild All started: Project: CUDATest001, Configuration: Debug x64 ------
1> CUDATestZeroZeroOne.cpp
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol threadIdx
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol blockIdx
1>CUDATestZeroZeroOne.obj : error LNK2001: unresolved external symbol blockDim
1>D:\Projects\CUDATest001\x64\Debug\CUDATest001.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
I am using vs2012 + CUDA 5.5. I started with a empty C++ win32 console project, added a .cpp file which includes all the code above. I am not even sure at this point should it be a .cu or a .cpp file?
Anyone has any idea how to make this work? Thanks.
In the context menu for your project, click Build Customizations. Turn on the CUDA 5.5 target.
In the context menu for your .cpp file, click Rename and rename it to .cu.
In the context menu for your .cu file (that you just renamed), select Properties. Then go to General and make sure Item Type is set to CUDA C/C++.
Rebuild.
When you start a new CUDA project, you can select Templates > NVIDIA > CUDA 5.5 > CUDA 5.5 Runtime to get a project that should compile without any modifications.
I'm trying to build a project that's using some functionality of the file system part of the Boost library and I keep getting linker errors.
I followed the Boost documentation to build it and it built successfully and then moved all the lib files from the stage directory to C:/boost/lib and the hpp files to C:/boost/include. I'm using Microsoft Visual Studio 2012 Express Edition. I've made sure to add the files (libboost_filesystem-vc110-mt-1_54.lib and libboost_system-vc110-mt-1_54.lib) in the properties page to the files that need to be linked in (I also tried it with the #pragma's explicitly). I tried both the .lib files containing gd and the ones that dont (the debugging ones and the ones that aren't for debugging).
My question is, how do I fix this? Did I build the files wrong? Did I specify some sort of linker property wrong?
Here's the errors (I omitted some to keep it short, if needed I can add them all):
Error 1 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ) C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
Error 2 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat#system#boost##YAXXZ) C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
[...]
Error 5 error LNK2019: unresolved external symbol "public: class boost::filesystem::path __cdecl boost::filesystem::path::root_path(void)const " (?root_path#path#filesystem#boost##QEBA?AV123#XZ) referenced in function main C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
Error 6 error LNK2019: unresolved external symbol "public: class boost::filesystem::path __cdecl boost::filesystem::path::root_name(void)const " (?root_name#path#filesystem#boost##QEBA?AV123#XZ) referenced in function main C:\Visual Studio 2012 Projects\MMS_Solution\MMS_Prj_FindFile\MMS_Prj_FindFile.obj MMS_Prj_FindFile
[...]
Error 18 error LNK1120: 17 unresolved externals C:\Visual Studio 2012 Projects\MMS_Solution\x64\Debug\MMS_Prj_FindFile.exe MMS_Prj_FindFile
Here's the linker options (if others are needed I can add them):
Linker -> General
Enabled Incremental Linking = Yes (/INCREMENTAL)
Ignore Import LIbrary = No
Register Output = No
Per-user Redirection = No
Additional Library Directories = C:\openssl\lib;C:\boost\lib
Link Library Dependencies = Yes
Use Library Dependency Inputs = No
Prevent Dll Binding =
Linker -> Input
All of these are blank except for
Additional Dependencies = ssleay32.lib;libeay32.lib;Ws2_32.lib;libboost_system-vc110-mt-1_54.lib;libboost_filesystem-vc110-mt-1_54.lib;%(AdditionalDependencies)
Here's the code:
//Boost Includes
#include <boost/filesystem.hpp>
//Boost linking because visual studio won't link it (ugh)
#pragma comment (lib, "libboost_system-vc110-mt-gd-1_54.lib")
#pragma comment (lib, "libboost_filesystem-vc110-mt-gd-1_54.lib")
//Normal Includes
#include <iostream>
#include <string>
namespace bfs = boost::filesystem;
int main(int argc, char* argv[])
{
std::vector<std::string> foundPaths;
bfs::directory_iterator eit;
for(bfs::directory_iterator it("."); it != eit; it++)
{
if(!bfs::is_regular_file(it->status()))
continue;
bfs::path foundPath = it->path();
foundPaths.push_back("Root name: " + foundPath.root_name().string() + "\n" +
"Root dir : " + foundPath.root_directory().string() + "\n" +
"Root path: " + foundPath.root_path().string() + "\n" +
"Rel path: " + foundPath.relative_path().string() + "\n" +
"Prnt path: " + foundPath.parent_path().string() + "\n" +
"File name: " + foundPath.filename().string() + "\n" +
"Stem : " + foundPath.stem().string() + "\n" +
"Extension: " + foundPath.extension().string() + "\n");
}
for(std::vector<std::string>::iterator it = foundPaths.begin(); it != foundPaths.end(); ++it)
{
std::cout << *it << std::endl;
}
return 0;
}
When building Boost, make sure that you're using the parameter "address-model=64" if you're building for 64 bit. It says in the documentation that your compiler should choose the right one if it is configured correctly but apparently mine was not and was building 32 bit binaries when I wanted 64 bit binaries.
EDITED:
My Problem is the errors at the bottom of this post.
Heres my additional include directories
C:\Program Files\boost
C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\include
C:\Program Files\MySQL\MySQL Server 5.6\include
Additional Library Directories
C:\Program Files\MySQL\MySQL Server 5.6\lib
C:\Program Files\MySQL\Connector C++ 1.1.2\lib\opt
Additional Dependencies
libmysql.lib
mysqlcppconn-static.lib
Heres my code
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#include <stdlib.h>
#include <Windows.h>
#include <mysql.h>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#define host "localhost"
#define username "root"
#define password "root"
#define database "tests"
int main()
{
MYSQL* conn;
conn = mysql_init( NULL );
if( conn )
{
mysql_real_connect( conn, host, username, password, database, 0, NULL, 0 );
}
MYSQL_RES* res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query( conn, "SELECT * FROM tbl_clients WHERE id = 1" );
res_set = mysql_store_result( conn );
unsigned int numrows = mysql_num_rows( res_set );
if( numrows )
{
row = mysql_fetch_row( res_set );
if( row != NULL )
{
cout << "Client ID : " << row[0] << endl;
cout << "Client Name: " << row[1] << endl;
}
}
if( res_set )
{
mysql_free_result( res_set );
}
if( conn )
{
mysql_close( conn );
}
return 0;
}
These are the errors I get
1>------ Build started: Project: okay, Configuration: Debug Win32 ------
1>welp.obj : error LNK2019: unresolved external symbol _mysql_num_rows#4 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_init#4 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_real_connect#32 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_query#8 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_store_result#4 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_free_result#4 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_fetch_row#4 referenced in function _main
1>welp.obj : error LNK2019: unresolved external symbol _mysql_close#4 referenced in function _main
1>C:\Users\Damian\documents\visual studio 2012\Projects\okay\Debug\okay.exe : fatal error LNK1120: 8 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please help, This project is due in about 48 hours for my class, and I've spent so much time trying to figure this out.
Thanks
respectfully, your last two questions are compiler/linker questions. I understand your frustration, as I knew how to code early but knew nothing about compilers/linkers. When you get a moment take some time to read about:
headers
binary vs object file
libraries / shared object
compiler
linker
function mangling (C vs C++)
To answer your question, I am guessing you're doing this in Microsoft Visual Studio:
You need to go to Project Properties and set Additional Library Paths (i see you did that from your last post)
You need to specify the library, I'm going out on a limb here and assuming it will mysql.lib ... There's an "Additional Library" input somewhere in the Linker section, you'll be able to identify it because kernel32.lib will be int it. Add the mysql.lib to that section. Confirm the name by going to the mysql folder which holds the binaries.
Make sure you're using the static library, the .dll will give you new issues that you don't need to worry about. This is usually achieved by setting the correct library directory. Many c++ libraries will ship with precompiled "Static" and "Dynamic" folders containing the correct libraries.
This is error is happening due to linker problem. The linker is not able to find the required static or dynamic libraries (mysql.lib,mysqlcppconn-static.lib,libmysql.dll and libmysql.lib). The additional lib setting is wrong. Check this site give the path correctly Building MySQL Connector/C++ Windows Applications with Microsoft Visual Studio
I'm attempting to compile a simple C file for use with Mathematica. (Note: I did follow the rest of the instructions, creating the empty addtwotm.c file and adding addtwo.tm)
#include "mathlink.h"
extern int addtwo( int i, int j);
int addtwo( int i, int j)
{
return i+j;
}
#if WINDOWS_MATHLINK
#if __BORLANDC__
#pragma argsused
#endif
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
{
char buff[512];
char FAR * buff_start = buff;
char FAR * argv[32];
char FAR * FAR * argv_end = argv + 32;
hinstPrevious = hinstPrevious; /* suppress warning */
if( !MLInitializeIcon( hinstCurrent, nCmdShow)) return 1;
MLScanString( argv, &argv_end, &lpszCmdLine, &buff_start);
return MLMain( (int)(argv_end - argv), argv);
}
#else
int main(int argc, char* argv[])
{
return MLMain(argc, argv);
}
#endif
However, on build, I get this output:
1>------ Build started: Project: addtwo, Configuration: Debug Win32 ------
1> Performing Custom Build Tools
1> on "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\VC\bin\mprep.exe" "" -o "D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\addtwo\..\addtwotm.c"
1>addtwo.obj : error LNK2019: unresolved external symbol _MLMain referenced in function _WinMain#16
1>addtwo.obj : error LNK2019: unresolved external symbol _MLInitializeIcon referenced in function _WinMain#16
1>D:\Applications\Mathematica\SystemFiles\Links\MathLink\DeveloperKit\Windows\MathLinkExamples\addtwo\Debug\addtwo.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've followed all provided instructions from Wolfram's MathLink Developer Guide, and made sure to add "ml32i3m.lib" to Linker>Input>Additional Dependencies. Supposedly the ml32/ml64 lib files contain the information for MlMain. Any help is appreciated :)
Can anybody please help me to configure Visual Studio 2005 (if that's the solution to the problem). I'm using some external libs and I'm getting this error:
1>Compiling...
1>main.cpp
1>c:\documents and settings\mz07\desktop\project\vs8test1\vs8test1\main.cpp(99) : warning C4996: 'getch' was declared deprecated
1> c:\program files\microsoft visual studio 8\vc\include\conio.h(145) : see declaration of 'getch'
1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.'
1>c:\documents and settings\mz07\desktop\project\vs8test1\vs8test1\main.cpp(110) : warning C4996: 'getch' was declared deprecated
1> c:\program files\microsoft visual studio 8\vc\include\conio.h(145) : see declaration of 'getch'
1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.'
1>c:\documents and settings\mz07\desktop\project\vs8test1\vs8test1\main.cpp(128) : warning C4996: 'getch' was declared deprecated
1> c:\program files\microsoft visual studio 8\vc\include\conio.h(145) : see declaration of 'getch'
1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.'
1>Compiling manifest to resources...
1>Linking...
1>hdu.lib(hduError.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (__imp_??6std##YAAAV?$basic_ostream#DU?$char_traits#D#std###0#AAV10#PBD#Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct HDErrorInfo const &)" (??6#YAAAV?$basic_ostream#DU?$char_traits#D#std###std##AAV01#ABUHDErrorInfo###Z)
1>C:\Documents and Settings\mz07\Desktop\project\vs8Test1\Debug\vs8Test1.exe : fatal error LNK1120: 1 unresolved externals
I've been googling it for hours. PLEASE, stackoverflow is my last hope!
Sorry I forgot to include the code:
#include "atl/stdafx.h"
#include <cstdio>
#include <cassert>
#if defined(WIN32)
# include <conio.h>
#else
# include "conio.h"
#endif
#include <HD/hd.h>
#include <HDU/hduVector.h>
#include <HDU/hduError.h>
#pragma comment(lib, "hdu.lib")
#pragma comment(lib, "hlu.lib")
#pragma comment(lib, "hd.lib")
#pragma comment(lib, "hl.lib")
/*******************************************************************************
Haptic sphere callback.
The sphere is oriented at 0,0,0 with radius 40, and provides a repelling force
if the device attempts to penetrate through it.
*******************************************************************************/
HDCallbackCode HDCALLBACK FrictionlessSphereCallback(void *data)
{
const double sphereRadius = 40.0;
const hduVector3Dd spherePosition(0,0,0);
// Stiffness, i.e. k value, of the sphere. Higher stiffness results
// in a harder surface.
const double sphereStiffness = .25;
hdBeginFrame(hdGetCurrentDevice());
// Get the position of the device.
hduVector3Dd position;
hdGetDoublev(HD_CURRENT_POSITION, position);
// Find the distance between the device and the center of the
// sphere.
double distance = (position-spherePosition).magnitude();
// If the user is within the sphere -- i.e. if the distance from the user to
// the center of the sphere is less than the sphere radius -- then the user
// is penetrating the sphere and a force should be commanded to repel him
// towards the surface.
if (distance < sphereRadius)
{
// Calculate the penetration distance.
double penetrationDistance = sphereRadius-distance;
// Create a unit vector in the direction of the force, this will always
// be outward from the center of the sphere through the user's
// position.
hduVector3Dd forceDirection = (position-spherePosition)/distance;
// Use F=kx to create a force vector that is away from the center of
// the sphere and proportional to the penetration distance, and scsaled
// by the object stiffness.
// Hooke's law explicitly:
double k = sphereStiffness;
hduVector3Dd x = penetrationDistance*forceDirection;
hduVector3Dd f = k*x;
hdSetDoublev(HD_CURRENT_FORCE, f);
}
hdEndFrame(hdGetCurrentDevice());
HDErrorInfo error;
if (HD_DEVICE_ERROR(error = hdGetError()))
{
hduPrintError(stderr, &error, "Error during main scheduler callback\n");
if (hduIsSchedulerError(&error))
{
return HD_CALLBACK_DONE;
}
}
return HD_CALLBACK_CONTINUE;
}
/******************************************************************************
main function
Initializes the device, creates a callback to handle sphere forces, terminates
upon key press.
******************************************************************************/
int main(int argc, char* argv[])
{
HDErrorInfo error;
// Initialize the default haptic device.
HHD hHD = hdInitDevice(HD_DEFAULT_DEVICE);
if (HD_DEVICE_ERROR(error = hdGetError()))
{
hduPrintError(stderr, &error, "Failed to initialize haptic device");
fprintf(stderr, "\nPress any key to quit.\n");
getch();
return -1;
}
// Start the servo scheduler and enable forces.
hdEnable(HD_FORCE_OUTPUT);
hdStartScheduler();
if (HD_DEVICE_ERROR(error = hdGetError()))
{
hduPrintError(stderr, &error, "Failed to start scheduler");
fprintf(stderr, "\nPress any key to quit.\n");
getch();
return -1;
}
// Application loop - schedule our call to the main callback.
HDSchedulerHandle hSphereCallback = hdScheduleAsynchronous(
FrictionlessSphereCallback, 0, HD_DEFAULT_SCHEDULER_PRIORITY);
printf("Sphere example.\n");
printf("Move the device around to feel a frictionless sphere\n\n");
printf("Press any key to quit.\n\n");
while (!_kbhit())
{
if (!hdWaitForCompletion(hSphereCallback, HD_WAIT_CHECK_STATUS))
{
fprintf(stderr, "\nThe main scheduler callback has exited\n");
fprintf(stderr, "\nPress any key to quit.\n");
getch();
break;
}
}
// For cleanup, unschedule our callbacks and stop the servo loop.
hdStopScheduler();
hdUnschedule(hSphereCallback);
hdDisableDevice(hHD);
return 0;
}
I think the library you're importing (hdu.lib) is built with a different runtime library - either you're mixing debug and release libraries here or static vs DLL runtimes.
It looks to me like you aren't linking in the C++ library. If you right-click on your project's "properties", and check Configuration Properties -> Linker -> Input, does your "Additional Dependencies" line include "libcpmt.lib" ?
It'd help if you could post the commandline switches the linker is running, by that I mean the full command.
It looks like this hdu libarary has a dependency on the C++ iostream library, can you check if your linker settings are specifying the iostream library.