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.
Related
I am following a tutorial here for creating a static library and using it for another project. So I want to create a .lib file and use it for another project.
Static library project:
MyMathLib.h
#define PI 3.1415;
double PowerOf2(double UserNumber);
double PowerOf3(double UserNumber);
double CircleArea(double UserRadius);
double CircleCircum(double UserRadius);
MyMathLib.cpp
#include "stdafx.h"
#include "MyMathLib.h"
double PowerOf2(double UserNumber) { return UserNumber * UserNumber; }
double PowerOf3(double UserNumber) { return UserNumber * UserNumber * UserNumber; }
double CircleArea(double UserRadius) { return UserRadius * UserRadius * PI; }
double CircleCircum(double UserRadius) { return 2 * UserRadius * PI; }
For the second project, I have done the following:
Add the MyMathLib vc project
Common Properties -> References -> Add New Reference
C/C++ -> General -> Additional Include Directories.
This is the C file that tries to call the library:
MyApps1.c
#include <stdio.h>
#include "MyMathLib.h"
int main()
{
double p2 = 10.0;
double radius = 4.0;
printf("The number %.2f to the power of 2 is %.2f. \n", p2, PowerOf2(p2));
printf("A circle with a radius of %.2f, the area is %.2f. \n", radius, CircleArea(radius));
return 0;
}
The error I am getting is:
1>------ Build started: Project: MyApps1, Configuration: Debug Win32 ------
1>MyApps1.obj : error LNK2019: unresolved external symbol _PowerOf2 referenced in function _main
1>MyApps1.obj : error LNK2019: unresolved external symbol _CircleArea referenced in function _main
1>c:\users\bandika\documents\visual studio 2013\Projects\MyApps1\Debug\MyApps1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
So there is a linking error somewhere. I have tried going to MyApps1 Properties -> Linker -> Input -> Additional Dependencies but I don't think I can add the .lib file for MyMathLib. Any idea what I'm missing?
Its related to linking of your static lib with the second project.
I don't see any problem in adding your generated static library name in "Configuration Properties -> Linker -> Input -> Additional Dependencies".
It should solve the linking problem.
Are you facing any other problem after using this option?
You do not have the second file added to the project in the VS.
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.
First I downloaded glut from this source, http://user.xmission.com/~nate/glut.html"> Nate Robins. I put:
glut32.dll into C:\Windows\SysWOW64,
glut32.lib into C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib
glut.h into C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL
In Visual Studio, under C++ I created an empty project, changed the compiler to 64x. I made sure to select ALL Configurations and linked opengl32.lib,glu32.lib and glut32.lib.
In Tools -> Options -> VC++ Directories -> Include Files:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
In Configuration Properties → Linker → Additional Library Directories:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib
/************************************
* Handout: example.cpp
*
* This program is to demonstrate the basic OpenGL program structure.
* Read the comments carefully for explanations.
************************************/
#define WINDOWS 1 /* Set to 1 for Windows, 0 else */
#define UNIX_LINUX 0 /* Set to 1 for Unix/Linux, 0 else */
#if WINDOWS
#include <windows.h>
#include <GL/glut.h>
#endif
#if UNIX_LINUX
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#endif
#include <stdio.h>
#include <math.h>
float f = 0.0;
void display(void);
void my_init(void);
void reshape(int w, int h);
void idle(void);
void main(int argc, char **argv)
{
/*---- Initialize & Open Window ---*/
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // double-buffering and RGB color
// mode.
glutInitWindowSize(500, 500);
glutInitWindowPosition(30, 30); // Graphics window position
glutCreateWindow("Rectangle"); // Window title is "Rectangle"
/*--- Register call-back functions; any order is fine ---*/
/* Events: display, reshape, keyboard, mouse, idle, etc.
- display: Automatically called when the window is first opened.
Later, when the frame content needs to be changed, we need
to call display again From the Program to re-draw the objects.
This is essential for animation.
- reshape: Automatically called when the window is first opened,
or when the window is re-sized or moved by the user.
- keyboard: Automatically called when a keyboard event occurs.
- mouse: Automatically called when a mouse event occurs.
- idle: Automatically called when nothing occurs.
This is essential for animation.
* Once entering the event loop, the execution control always returns to
the event loop. When particular event occurs, the corresponding call-back
function is called; when that call-back function finishes, control again
goes back to the event loop, and the process is repeated.
*/
glutDisplayFunc(display); // Register our display() function as the display
// call-back function
glutReshapeFunc(reshape); // Register our reshape() function as the reshape
// call-back function
// glutMouseFunc(mouse); // for mouse
// glutKeyboardFunc(key); // for keyboard
glutIdleFunc(idle); // Register our idle() function
my_init(); // initialize variables
glutMainLoop(); // Enter the event loop
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT); // clear frame buffer (also called the
// color buffer)
glColor3f(0.0, 1.0, 1.0); // draw in cyan.
// The color stays the same until we
// change it next time.
glBegin(GL_POLYGON); // Draw a polygon (can have many vertices)
// The vertex coordinates change by different
// values of i; see also function idle().
glVertex2f(100, 100 + f);
glVertex2f(200, 100 + f);
glVertex2f(200, 300 + f);
glVertex2f(100, 300 + f);
glEnd();
glFlush(); // Render (draw) the object
glutSwapBuffers(); // Swap buffers in double buffering.
}
void my_init()
{
glClearColor(0.0, 0.0, 0.0, 0.0); // Use black as the color for clearing
// the frame buffer (also called the
// color buffer). This produces a
// black background.
}
void reshape(int w, int h)
{
glViewport(0, 0, w, h); // Viewport within the graphics window.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
}
void idle(void)
{
f += 0.02; // smaller number gives a slower but smoother animation
if (f > 180.0) f = 0.0;
glutPostRedisplay(); // or call display()
}
My errors are
Error 17 error LNK1120: 16 unresolved externals C:\Projects\Project1\x64\Debug\Project1.exe Project1
Error 15 error LNK2001: unresolved external symbol _fltused C:\Projects\Project1\Project1\main.obj Project1
Error 13 error LNK2001: unresolved external symbol _RTC_InitBase C:\Projects\Project1\Project1\main.obj Project1
Error 14 error LNK2001: unresolved external symbol _RTC_Shutdown C:\Projects\Project1\Project1\main.obj Project1
Error 16 error LNK2001: unresolved external symbol mainCRTStartup C:\Projects\Project1\Project1\LINK Project1
Error 7 error LNK2019: unresolved external symbol __imp___glutCreateWindowWithExit referenced in function glutCreateWindow_ATEXIT_HACK C:\Projects\Project1\Project1\main.obj Project1
Error 2 error LNK2019: unresolved external symbol __imp___glutInitWithExit referenced in function glutInit_ATEXIT_HACK C:\Projects\Project1\Project1\main.obj Project1
Error 1 error LNK2019: unresolved external symbol __imp_exit referenced in function glutInit_ATEXIT_HACK C:\Projects\Project1\Project1\main.obj Project1
Error 10 error LNK2019: unresolved external symbol __imp_glutDisplayFunc referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 12 error LNK2019: unresolved external symbol __imp_glutIdleFunc referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 3 error LNK2019: unresolved external symbol __imp_glutInitDisplayMode referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 4 error LNK2019: unresolved external symbol __imp_glutInitWindowPosition referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 5 error LNK2019: unresolved external symbol __imp_glutInitWindowSize referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 6 error LNK2019: unresolved external symbol __imp_glutMainLoop referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 8 error LNK2019: unresolved external symbol __imp_glutPostRedisplay referenced in function "void __cdecl idle(void)" (?idle##YAXXZ) C:\Projects\Project1\Project1\main.obj Project1
Error 11 error LNK2019: unresolved external symbol __imp_glutReshapeFunc referenced in function main C:\Projects\Project1\Project1\main.obj Project1
Error 9 error LNK2019: unresolved external symbol __imp_glutSwapBuffers referenced in function "void __cdecl display(void)" (?display##YAXXZ) C:\Projects\Project1\Project1\main.obj Project1
Cannot figure out what I'm doing wrong.
You are using 32bit libraries but you are compiling a x64 executable and the linker cannot resolve the symbols.
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 :)
I'm trying to get this accurate timer working on VS2008, on Windows XP (and eventually Server 2008) from the following example:
http://technology.chtsai.org/w98timer/
However I get the following errors:
error LNK2019: unresolved external symbol _imp_timeEndPeriod#4
error LNK2019: unresolved external symbol _imp_timeGetTime#0
error LNK2019: unresolved external symbol _imp_timeBeginPeriod#4
error LNK2019: unresolved external symbol _imp_timeGetDevCaps#8
Could anybody please advise?
I just want a simple, accurate, millisecond-timing example for C++ on Windows.
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include "stdafx.h"
void
main (void)
{
TIMECAPS resolution;
DWORD start, finish, duration, i;
if (timeGetDevCaps (&resolution, sizeof (TIMECAPS)) == TIMERR_NOERROR)
{
printf ("Minimum supported resolution = %d\n", resolution.wPeriodMin);
printf ("Maximum supported resolution = %d\n", resolution.wPeriodMax);
}
if (resolution.wPeriodMin <= 1)
{
if (timeBeginPeriod (1) == TIMERR_NOERROR)
{
for (i = 100; i <= 120; i++)
{
start = timeGetTime ();
while (timeGetTime () < (start + i));
finish = timeGetTime ();
duration = finish - start;
printf ("expected:%d actual:%ld\n", i, duration);
}
timeEndPeriod (1);
}
}
}
As MSDN suggests you need to include winmm.lib into the project. So add the following line anywhere into your source code:
#pragma comment(lib, "winmm.lib")
Looking at the docs it looks like you need to add Winmm.lib to the additional libraries to link in your project properties.
You need to add winmm.lib to your linker dependencies.
These functions are defined in winmm.dll. You need to add winmm.lib to your link list.