LNK1104 cannot open file 'ucrtd.lib' in VS2015 - visual-studio

so i don't know a lot for VS2015
i downlode it because i want to use it in my University to use OpenGL
so i have this problem and i didn't fine any way to fix it
first of all i install the program in disk D:
i have made a project in C and D and got the same problem
i try to run it without debug and without cod
"Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file 'ucrtd.lib' ConsoleApplication2 D:\Users\Anmar\documents\visual studio 2015\Projects\ConsoleApplication2\ConsoleApplication2\LINK 1
"
this is photo for the problem when i add some code and run it
http://screencast.com/t/znmUrht6vyg
the code was
#include <glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glClearColor(1.0, 1.0, 1.0, 0.0);
glutDisplayFunc(display);
glutMainLoop();
}
so any way to fix this ?

I think your question may be similar to this one:
How to I update my C++ project in Visual Studio 2015 to use the new Universal CRT?
I had to do a couple things to get older C++ projects to work with VS2015.
First, I had to make sure I installed MFC as part of VS2015.
Second, I needed to add to my LibraryPath, for my 32-bit project:
$(UniversalCRT_LibraryPath_x86)
So now my vcxproj file has this for its LibraryPath
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\WinDDK\7600.16385.1\lib\wxp\i386;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir_71A)lib;$(UniversalCRT_LibraryPath_x86)</LibraryPath>
Third, I had to refresh my understanding of the variety of C Run-Time libraries with VS2015, since they have changed a little bit. Here's the link to CRT Library Features on MSDN, which explains how all the switches affect what in VS2015:
https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
Some of my vcxproj switches were mismatched with what MSDN said. It took a little effort to get them all straightened out.
Then I realized I had only done my Debug configuration. I had to also make all the changes all over again to my Release configuration. Good safety tip.
Hope that helps!

Related

Iterator issue in VC++ project in Visual Studio 2013

I am migrating the visual studio 2008 vc++ projects to visual studio 2013. I am facing c3892 when migrating one of my projects.Here I am providing sample piece of code which reproduces the the error Iam facing in migration.
int _tmain(int argc, _TCHAR* argv[]){
int myints[] = {21,64,17,78,49};
std::set<int> myset (myints,myints+5);
std::set<int>::reverse_iterator rit;
std::cout << "myset contains:";
for (rit=myset.rbegin(); rit != myset.rend(); ++rit)
if(*rit==64)
*rit=90;
return 0;
}
If we execute the above piece of code in vs2013 ,Iam throwing an error
Error error C3892: 'std::_Revranit<_RanIt,_Base>::operator *' : you cannot assign to a variable that is const
But if we execute the same piece of code visual studio 2008, Iam not getting any type of errors the build is successful.
I must change the value in my project.
Please provide me the solution how to get rid of this error.
Thanks in advance.
phani
Simply put, you're not allowed to directly modify elements of a set after they've been inserted (http://www.cplusplus.com/reference/set/set/). If you changed set to vector in your example, it would compile just fine.
If you want to modify an element from a set, you must erase it from the set and then insert the modified value.
Actually, this stackoverflow question is identical to yours and has some cool workarounds suggested.

Uninstall software

My product has a helper executable to uninstall all related sub-products. I uninstall based on upgrade codes of all sub-products.
First, I fetch the product code from upgrade code using MsiEnumRelatedProducts function. Then I try to uninstall the product using MsiConfigureProductEx function.
The problem is MsiConfigureProductEx is returning error.
Invoked Function: MsiConfigureProductsEx
Return Code: 1605 (0x00000645)
Description: This action is only valid for products that are currently installed.
Why is MsiEnumRelatedProducts returning a invalid product code ? I searched through the windows registry to see if such product code exists. There isn't any. How to debug the issue ?
Edit: Added minimum code that reproduces issue.
// UpgradeCodes is an array having upgrade codes of all modules.
TCHAR lpProductCode[GUID_STR_LENGTH];
const TCHAR tszNoReboot[] = _T("REMOVE=ALL REBOOT=ReallySuppress DISABLE_REBOOT_PROMPT=1");
for (size_t i = 0; i < sizeof(UpgradeCodes) / sizeof(UpgradeCodes[0]); i++)
{
tstring tstrUpgradeCode = UpgradeCodes[i];
DWORD dwIndex = 0;
size_t status;
// for each of the upgrade code, get all the products
do
{
status = MsiEnumRelatedProducts(UpgradeCodes[i],
0,
dwIndex,
lpProductCode);
if (ERROR_SUCCESS == status)
{
UINT uiReturn = MsiConfigureProductEx(lpProductCode,
INSTALLLEVEL_DEFAULT,
INSTALLSTATE_DEFAULT,
tszNoReboot);
if (ERROR_SUCCESS_REBOOT_REQUIRED == uiReturn)
{
// prompt for reboot at the end of all modules uninstallation.
}
if (ERROR_SUCCESS != uiReturn)
{
// log message with return code.
// Error Code: 1605 is coming from here.
}
}
}while (ERROR_NO_MORE_ITEMS != status);
}
Some years have passed and I want to add two scipts that can be used
to export MSI package information:
How can I find the product GUID of an installed MSI setup? - in section 2.
Do visit the link above, but here are direct links to the scripts:
1) the html export version and 2) the simpler text output.
Disclaimer: The below information is very "under the hood". Please use API calls whenever you can to access the MSI database. Also remember to run all your MSI testing on virtual machines so you can easily revert to a "clean state". During MSI development strange things can happen.
It is possible that a previous uninstall of that product of yours left something registered upon uninstall, and this is causing all the problems. I would try to check with scripts what is registered on the system.
Found good discussions of retrieving product info with VBScript here, a couple of really good scripts - recommended. Go to the sites to find the scripts, they format pretty poorly here and clog the answer.
http://forum.installsite.net/index.php?act=ST&f=26&t=14035
http://www.dwarfsoft.com/blog/2010/06/22/msi-package-code-fun/
The Windows Installer database is mostly located here:
HKEY_CLASSES_ROOT\Installer\
The upgrade code section: HKEY_CLASSES_ROOT\Installer\UpgradeCodes
You must never touch anything in the Windows Installer Database Registry directly. It's extremely interconnected and easy to corrupt. Only go through the APIs. Note that the GUIDs in the registry are packed, so you won't find the GUIDs from the package in the registry.
Packed GUID: 03B1692A57845354EA63AD602436AB05
Regular GUID: {A2961B30-4875-4535-AE36-DA064263BA50}
Using the VBScripts above and the registry data directly for inspection you should be able to determine what is happening in the Windows Installer database.
I would never work straight in C++ to test this out. Instead I would eliminate some complexity by trying PowerShell or VBScript to determine what is wrong with the uninstall routine. You can find information on how to use these scripting tools here in this thread. And here is another thread.
It is not quite clear if some of the uninstalls work, and there is
one that fails or if the uninstall operation fails altogether? That's
the first question.
Have you tried manually uninstalling all products from add/remove to ensure they all uninstall correctly manually? One of the products could trigger an error return code during uninstall that is caught programatically, but is ignored during manual install. Often these can be from Custom Actions placed after InstallFinalize. In this case some setup redesign is called for. In the simplest case it would involve disabling error checking for the custom action, but that fix is not good enough in my opinion.
It is possible that the product is
installed, but per-user. In other words it might be installed only
for a single user on the machine, and not for the machine (this is controlled by the ALLUSERS property). I am not sure how this function works if this is the case - it may even report the product as advertised (available for on demand install via a shortcut, but not actually installed). Again, I have not tried this, and uninstall may still work. Just off the top of my head to try and give you some pointers.
Have you performed any major upgrades of existing MSI files as part of the install of your product?
One further question: are you running on Windows 8? And are these MSI files generated with WIX or some other tool? There have been some intermittent reports on problems that appear at least remotely similar.
If you have a package installer (like Microsoft SQL Server), it can install a host of other items during its installation phase.
Later, when you go to uninstall the big package installer, all of the items that installer added to the system should theoretically be removed.
So, try just uninstalling your application, stop, then look to see if the other smaller applications are still on the system.
If they are, then you will need to uninstall these individual applications first when your custom uninstall script starts.
I assume you already have a System.Configuration.Install.Installer class. Follow a set of steps when installing your application (1, 2, 3, etc.), then perform these steps in reverse order when uninstalling your application (3, 2, 1).
Trying a new approach for you. I have located two products that seem to have at least two productcodes registered for their upgrade codes. They are: MSVC redistributable 2008 and MSXML 4.0 SP2. I have written a small C++ test that seems to work ok.
Essentially I think you need to check for ERROR_NO_MORE_ITEMS before the next iteration of the loop so you don't try to uninstall products that are no longer installed.
Here is some VS2013 code that should compile out of the box on a fresh install, empty project.
UPDATE: updated code to use VS2017 and a minimal console application.
Create a new console project: File => New => Project... => Visual C++, Windows Desktop, Windows Console Application
Paste the below code into the main CPP file (replacing whatever is there)
Set a breakpoint and build & run (F5)
F10 to step through
If "Microsoft Visual C++ 2008 Redistributable" isn't installed, no related product codes will be found.
#pragma once
#include "stdafx.h"
// The below should really be in stdafx.h (precompiled header)
#define WIN32_LEAN_AND_MEAN // Exclude stuff from Windows.h
#define STRICT
#include <windows.h>
#include <msi.h>
#pragma comment(lib, "msi.lib") // To make code link
int main()
{
UINT i = 0;
UINT status = ERROR_SUCCESS;
TCHAR productcode[39] = {};
const TCHAR upgradecode[39] = L"{AA783A14-A7A3-3D33-95F0-9A351D530011}"; //Microsoft Visual C++ 2008 Redistributable
//const TCHAR upgradecode[39] = L"{7CE723E3-E56B-432C-9F24-78C0606045A5}"; // MSXML 4.0 SP2 (KB973688)
do
{
// look up (related) product code(s) for specified upgrade code
status = MsiEnumRelatedProducts(upgradecode, 0, i, productcode);
if (status == ERROR_NO_MORE_ITEMS) // Test here. 259, ERROR_NO_MORE_ITEMS
{
// No more productcodes for specified upgrade code
MessageBox(NULL, L"No more productcodes", L"Done", MB_OK);
break; // exit do-while loop
}
i++; // Next product code
MessageBox(NULL, productcode, L"Product Code:", MB_OK);
} while (status != ERROR_NO_MORE_ITEMS);
return 0;
}
There could be erronously registered products on your system due to failed major upgrades or similar advanced error scenarios, so I am not sure if this solves your problem.
Keep in mind that the Windows Installer Database at HKEY_CLASSES_ROOT\Installer\UpgradeCodes contains packed GUIDs. You can try the VBScript code found in the following link to convert back and forth between packed and regular GUID formats: http://www.symantec.com/connect/blogs/guid-converter
More info on guid formats here if it is interesting: http://www.symantec.com/connect/articles/working-darwin-descriptors
// TEST DATA 2014 (guids in different formats):
// UpgradeCode
// 41A387AA3A7A33D3590FA953D1350011 => {AA783A14-A7A3-3D33-95F0-9A351D530011}
//
// ProductCode
//
// Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
// CFD2C1F142D260E3CB8B271543DA9F98 => {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
//
// Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17
// D20352A90C039D93DBF6126ECE614057 => {9A25302D-30C0-39D9-BD6F-21E6EC160475}
// UpgradeCode
// 3E327EC7B65EC234F942870C0606545A => {7CE723E3-E56B-432C-9F24-78C0606045A5}
//
// ProductCode
//
// MSXML 4.0 SP2 (KB973688)
// 6E8A266FCD4F2A1409E1C8110F44DBCE => {F662A8E6-F4DC-41A2-901E-8C11F044BDEC}
// MSXML 4.0 SP2 (KB954430)
// DDA39468D428E8B4DB27C8D5DC5CA217 => {86493ADD-824D-4B8E-BD72-8C5DCDC52A71}

CUDA __syncthreads() compiles fine but is underlined with red

I have been working with CUDA 4.2 for a week now and I have a little problem.
When I write the __syncthreads() function it becomes underlined and looks like it is wrong...
Then if I put the mouse on the function it appears a message writing:
identifier __syncthreads(); is undefined.
but when i compile my project the output form build says:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
So I am guessing that everything works fine but the fact that Visual Studio underlines the function is confusing me...How can I make Visual studio to know that this function is defined before the compiling process?
NOTE:The same thing happens with the kernel call: kernel<<<...,...>>> where the third "<" is underlined red too...
I know that this probably is a minor problem but i want to solve it...Thanks a lot!
I am using Visual Studio 2010 on win7 with Cuda 4.2 and Nsight 2.2
I added the following few lines to the top of the cu file and it began to recognize these functions. For some reason, Intellisense did not pick up this #define:
#ifndef __CUDACC__
#define __CUDACC__
#endif
I lost some color-coding in the code, but I no longer get strange false positive errors.
I am using CUDA 9.1 and Visual Studio 2017 15.6.4. The following code helps me eliminate the "__syncthreads() is undefined" error.
//for __syncthreads()
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include <device_functions.h>
However, this method is not recommended because it may bring unpredictable side effects. Another method to solve this intellisense warning is:
#ifdef __INTELLISENSE___
// in here put whatever is your favorite flavor of intellisense workarounds
#endif
Reference:
__syncthreads(); is undefined need a help
I have CUDA 8.0 and Visual Studio 2015 and I had the same issue.
The below lines helped me:
After these lines: (already in code)
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
I added these lines:
//for __syncthreads()
#ifndef __CUDACC_RTC__
#define __CUDACC_RTC__
#endif // !(__CUDACC_RTC__)
#include <device_functions.h>
It's based on this link: https://devtalk.nvidia.com/default/topic/1009723/__syncthreads-and-atomicadd-are-undefined-in-visual-studio-2015/
Experienced this when trying to define the body of __global__ functions in .cuh files. Moving the body of the functions into .cu source-file solved it.
However, it means that some of my templated functions can't use essential things like __syncthreads(), because templates might have to be defined in a .cuh header.
So, you might need to abandon function templates and instead stick to several functions, each with a slightly different name.
The other solutions either did not solve the same issue occurring in Eclipse 2021-06 with CMake 3.16.3, or produced the following warning with CUDA Runtime Version = 10.1:
/usr/include/device_functions.h:54:2: warning: #warning "device_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release.
The following gave proper highlighting and code completion in Eclipse, and it didn't produce compile warning:
#ifndef __CUDACC__
#define __CUDACC__
#include <device_functions.h>
#endif

OpenGL include statements

I'm attempting to work with openGL in visual studio 2010, and so far my code looks like so
#include<gl\GLU.h>
#include<gl\GL.h>
int main(int argc, char**argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 480);
glutCreateWindow("Simple GLUT application");
glutMainLoop();
}
Visual studio is not recognizing any of the glut methods and is throwing errors such as "glutInit not recognized"
I know it is some error with how I linked the libraries, but I am new at this, so please be kind. Anyone know how to get this example working properly?
You need to include the glut headers. Glut is the "GL utility toolkit" and is a separate library built on top of OpenGL, not part of OpenGL itself.
If you have them in the same directory as your other includes, it would read
#include<gl\GLUT.h>
For more info: here
Did you make sure that you copied glut32.dll to %windir%\system and glut.h to %VSdir%\VC\include\GL and glut32.lib to %VSdir%\lib? If you did it right then you shall see the Open GL methods in the intellisense.

Run Objective-C in Xcode without starting up simulator

I would like to run my Objective-C code inside Xcode, but not for the iPhone or Mac. I want to write programs to solve the challenges from Project Euler, without starting up the simulator. I am using NSLog() to display my results, and that's all I need.
How can I do this? I checked everywhere but all I found were questions about how to run Objective-C outside of Xcode and so on.
If I'm understanding right, you want to create a "Command-Line Tool", one of the options under the Mac OS X templates:
That'll give you a project containing just one code file, main.m:
// main.m
// Project Euler Puzzle #N
//
// Created by pnizzle on 8/7/12.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
#autoreleasepool {
}
return 0;
}
It's linked against Foundation and compiled as ObjC, so you can do pretty much anything you would do in a GUI app (except the GUI parts, of course), including creating your own classes. main() is the entry point for your program; just put whatever you want to do inside that #autoreleasepool block.
An alternative to using the Command Line Tool option in Xcode is the CodeRunner app, available in the Mac App Store. CodeRunner allows you to run short snippets of Objective-C code without the overhead of Xcode.
CodeRunner also supports a number of other languages: C, Java, JavaScript, Lua, Perl, PHP etc
CodeRunner currently costs about $10, I have found it to be very useful to quickly test short snippets of code in a number of languages.
I believe you will need to install the Command Line Tools package from Xcode -> Preferences -> Downloads for CodeRunner to use.
http://krillapps.com/coderunner/
Choosing "Command-Line Tool"will do the job for you. You will see the output in the bottom when you run the code.

Resources